Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-10-16 10:25:19 +0300
committerStan Hu <stanhu@gmail.com>2015-10-16 10:33:58 +0300
commit888c1a3fc53ff0318cd69d0e7f1edad25f306713 (patch)
tree08229c0a3ab225a9a13ae8e1e75d1f180727191f /spec/services
parentbf290a52b7589ccd0e37a224ec36cec28acfb6a8 (diff)
Add spec for refresh service adding notes to restored branches
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/merge_requests/refresh_service_spec.rb24
-rw-r--r--spec/services/system_note_service_spec.rb4
2 files changed, 15 insertions, 13 deletions
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb
index 41eb5d41b2e..463cd594fb0 100644
--- a/spec/services/merge_requests/refresh_service_spec.rb
+++ b/spec/services/merge_requests/refresh_service_spec.rb
@@ -108,21 +108,23 @@ describe MergeRequests::RefreshService do
context 'push new branch that exists in a merge request' do
let(:refresh_service) { service.new(@fork_project, @user) }
- before do
- allow(refresh_service).to receive(:execute_hooks)
+
+ it 'refreshes the merge request' do
+ expect(refresh_service).to receive(:execute_hooks).
+ with(@fork_merge_request, 'update')
+ allow_any_instance_of(Repository).to receive(:merge_base).and_return(@oldrev)
+
refresh_service.execute(Gitlab::Git::BLANK_SHA, @newrev, 'refs/heads/master')
reload_mrs
- end
- it 'should execute hooks with update action' do
- expect(refresh_service).to have_received(:execute_hooks).
- with(@fork_merge_request, 'update')
- end
+ expect(@merge_request.notes).to be_empty
+ expect(@merge_request).to be_open
- it { expect(@merge_request.notes).to be_empty }
- it { expect(@merge_request).to be_open }
- it { expect(@fork_merge_request.notes.last.note).to include('Source branch `master` restored') }
- it { expect(@fork_merge_request).to be_open }
+ notes = @fork_merge_request.notes.reorder(:created_at).map(&:note)
+ expect(notes[0]).to include('Source branch `master` restored')
+ expect(notes[1]).to include('Added 4 commits')
+ expect(@fork_merge_request).to be_open
+ end
end
def reload_mrs
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index 16b1c66ff9a..699b2e3441f 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -229,7 +229,7 @@ describe SystemNoteService do
end
describe '.change_branch' do
- subject { described_class.change_branch(noteable, project, author, :target, old_branch, new_branch) }
+ subject { described_class.change_branch(noteable, project, author, 'target', old_branch, new_branch) }
let(:old_branch) { 'old_branch'}
let(:new_branch) { 'new_branch'}
@@ -243,7 +243,7 @@ describe SystemNoteService do
end
describe '.change_branch_presence' do
- subject { described_class.change_branch_presence(noteable, project, author, 'source', 'feature', :delete) }
+ subject { described_class.change_branch_presence(noteable, project, author, :source, 'feature', :delete) }
it_behaves_like 'a system note'