diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-02-28 21:28:43 +0100 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-02-28 21:28:43 +0100 |
commit | a2f375e8f74870dcdcfa1c7886bd1c14c80a684e (patch) | |
tree | 6b6e3a4f7554f4671edc17d87869dd6916984404 /spec/services/issues | |
parent | a22f6fa6e50bb31921415b01fd345d6802581390 (diff) | |
parent | 81852d1f902c2923c239e9c33cab77f5fd6ca8d8 (diff) | |
download | gitlab-ce-a2f375e8f74870dcdcfa1c7886bd1c14c80a684e.tar.gz |
Merge remote-tracking branch 'origin/master' into object-storage-ee-to-ce-backportobject-storage-ee-to-ce-backport
Diffstat (limited to 'spec/services/issues')
-rw-r--r-- | spec/services/issues/fetch_referenced_merge_requests_service_spec.rb | 35 | ||||
-rw-r--r-- | spec/services/issues/move_service_spec.rb | 22 |
2 files changed, 57 insertions, 0 deletions
diff --git a/spec/services/issues/fetch_referenced_merge_requests_service_spec.rb b/spec/services/issues/fetch_referenced_merge_requests_service_spec.rb new file mode 100644 index 00000000000..4e58179f45f --- /dev/null +++ b/spec/services/issues/fetch_referenced_merge_requests_service_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper.rb' + +describe Issues::FetchReferencedMergeRequestsService do + let(:project) { create(:project) } + let(:issue) { create(:issue, project: project) } + let(:other_project) { create(:project) } + + let(:mr) { create(:merge_request, source_project: project, target_project: project, id: 2)} + let(:other_mr) { create(:merge_request, source_project: other_project, target_project: other_project, id: 1)} + + let(:user) { create(:user) } + let(:service) { described_class.new(project, user) } + + context 'with mentioned merge requests' do + it 'returns a list of sorted merge requests' do + allow(issue).to receive(:referenced_merge_requests).with(user).and_return([other_mr, mr]) + + mrs, closed_by_mrs = service.execute(issue) + + expect(mrs).to match_array([mr, other_mr]) + expect(closed_by_mrs).to match_array([]) + end + end + + context 'with closed-by merge requests' do + it 'returns a list of sorted merge requests' do + allow(issue).to receive(:closed_by_merge_requests).with(user).and_return([other_mr, mr]) + + mrs, closed_by_mrs = service.execute(issue) + + expect(mrs).to match_array([]) + expect(closed_by_mrs).to match_array([mr, other_mr]) + end + end +end diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index e91faea00b7..a9aee9e100f 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -232,6 +232,28 @@ describe Issues::MoveService do end end + context 'issue with assignee' do + let(:assignee) { create(:user) } + + before do + old_issue.assignees = [assignee] + end + + it 'preserves assignee with access to the new issue' do + new_project.add_reporter(assignee) + + new_issue = move_service.execute(old_issue, new_project) + + expect(new_issue.assignees).to eq([assignee]) + end + + it 'ignores assignee without access to the new issue' do + new_issue = move_service.execute(old_issue, new_project) + + expect(new_issue.assignees).to be_empty + end + end + context 'notes with references' do before do create(:merge_request, source_project: old_project) |