diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/merge_requests/update_service_spec.rb | 11 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 14 |
2 files changed, 24 insertions, 1 deletions
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb index 0a0760056cf..c75173c1452 100644 --- a/spec/services/merge_requests/update_service_spec.rb +++ b/spec/services/merge_requests/update_service_spec.rb @@ -20,7 +20,8 @@ describe MergeRequests::UpdateService do description: 'Also please fix', assignee_id: user2.id, state_event: 'close', - label_ids: [label.id] + label_ids: [label.id], + target_branch: 'target' } end @@ -39,6 +40,7 @@ describe MergeRequests::UpdateService do it { expect(@merge_request).to be_closed } it { expect(@merge_request.labels.count).to eq(1) } it { expect(@merge_request.labels.first.title).to eq('Bug') } + it { expect(@merge_request.target_branch).to eq('target') } it 'should execute hooks with update action' do expect(service).to have_received(:execute_hooks). @@ -77,6 +79,13 @@ describe MergeRequests::UpdateService do expect(note).not_to be_nil expect(note.note).to eq 'Title changed from **Old title** to **New title**' end + + it 'creates system note about branch change' do + note = find_note('Target') + + expect(note).not_to be_nil + expect(note.note).to eq 'Target branch changed from `master` to `target`' + end end end end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 0dcc94e8bd4..700286b585a 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -228,6 +228,20 @@ describe SystemNoteService do end end + describe '.change_branch' do + subject { described_class.change_branch(noteable, project, author, 'target', old_branch, new_branch) } + let(:old_branch) { 'old_branch'} + let(:new_branch) { 'new_branch'} + + it_behaves_like 'a system note' + + context 'when target branch name changed' do + it 'sets the note text' do + expect(subject.note).to eq "Target branch changed from `#{old_branch}` to `#{new_branch}`" + end + end + end + describe '.cross_reference' do subject { described_class.cross_reference(noteable, mentioner, author) } |