diff options
author | Patrick Bajao <ebajao@gitlab.com> | 2019-06-28 14:08:26 -0800 |
---|---|---|
committer | Patrick Bajao <ebajao@gitlab.com> | 2019-06-29 00:22:09 +0800 |
commit | 1ca5520bd6f3447ada3a1120d2a3bd445ab6746a (patch) | |
tree | 30de757277f2948f38357fc78b3b1792975394d3 /spec/services | |
parent | ac3de494bde32e4ce13bd665d1de3132b84c002d (diff) | |
download | gitlab-ce-1ca5520bd6f3447ada3a1120d2a3bd445ab6746a.tar.gz |
Fix issues when creating system notes58583-confidential-mr-branch-backend
When `confidential_issue_project_id` is set and the issue is
under that project, create the a note about branch creation
in that project. If not, do nothing.
When creating `new_merge_request` system note, set the project
where the MR will be referenced from so it'll be linked to when
the MR is created in another project.
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/merge_requests/create_from_issue_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 32 |
2 files changed, 26 insertions, 10 deletions
diff --git a/spec/services/merge_requests/create_from_issue_service_spec.rb b/spec/services/merge_requests/create_from_issue_service_spec.rb index 2c83b2851a1..0e0da6a13ab 100644 --- a/spec/services/merge_requests/create_from_issue_service_spec.rb +++ b/spec/services/merge_requests/create_from_issue_service_spec.rb @@ -48,7 +48,7 @@ describe MergeRequests::CreateFromIssueService do end it 'creates the new_merge_request system note' do - expect(SystemNoteService).to receive(:new_merge_request).with(issue, target_project, user, instance_of(MergeRequest)) + expect(SystemNoteService).to receive(:new_merge_request).with(issue, project, user, instance_of(MergeRequest)) service.execute end @@ -56,7 +56,7 @@ describe MergeRequests::CreateFromIssueService do it 'creates the new_issue_branch system note when the branch could be created but the merge_request cannot be created' do expect_any_instance_of(MergeRequest).to receive(:valid?).at_least(:once).and_return(false) - expect(SystemNoteService).to receive(:new_issue_branch).with(issue, target_project, user, issue.to_branch_name) + expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, issue.to_branch_name, branch_project: target_project) service.execute end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 93fe3290d8b..97377c2f560 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -454,16 +454,32 @@ describe SystemNoteService do end describe '.new_issue_branch' do - subject { described_class.new_issue_branch(noteable, project, author, "1-mepmep") } + let(:branch) { '1-mepmep' } - it_behaves_like 'a system note' do - let(:action) { 'branch' } - end + subject { described_class.new_issue_branch(noteable, project, author, branch, branch_project: branch_project) } - context 'when a branch is created from the new branch button' do - it 'sets the note text' do - expect(subject.note).to start_with("created branch [`1-mepmep`]") + shared_examples_for 'a system note for new issue branch' do + it_behaves_like 'a system note' do + let(:action) { 'branch' } end + + context 'when a branch is created from the new branch button' do + it 'sets the note text' do + expect(subject.note).to start_with("created branch [`#{branch}`]") + end + end + end + + context 'branch_project is set' do + let(:branch_project) { create(:project, :repository) } + + it_behaves_like 'a system note for new issue branch' + end + + context 'branch_project is not set' do + let(:branch_project) { nil } + + it_behaves_like 'a system note for new issue branch' end end @@ -477,7 +493,7 @@ describe SystemNoteService do end it 'sets the new merge request note text' do - expect(subject.note).to eq("created merge request #{merge_request.to_reference} to address this issue") + expect(subject.note).to eq("created merge request #{merge_request.to_reference(project)} to address this issue") end end |