diff options
author | Robert Speicher <rspeicher@gmail.com> | 2019-07-29 13:19:50 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2019-07-29 13:19:50 -0500 |
commit | fe22704a203111ab2146143a4ff9d2e1256aecc7 (patch) | |
tree | 1bafbd0bdfbd498220cef09c94eb71bf4f9e072f /spec/services/merge_requests/build_service_spec.rb | |
parent | f039d592aa6203502be487801777167e433ad9d2 (diff) | |
parent | cc7b15fe935d41aab85918eb7ae7c0ef81f8bfb0 (diff) | |
download | gitlab-ce-fe22704a203111ab2146143a4ff9d2e1256aecc7.tar.gz |
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
Diffstat (limited to 'spec/services/merge_requests/build_service_spec.rb')
-rw-r--r-- | spec/services/merge_requests/build_service_spec.rb | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb index 5c3b209086c..f18239f6d39 100644 --- a/spec/services/merge_requests/build_service_spec.rb +++ b/spec/services/merge_requests/build_service_spec.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true - require 'spec_helper' describe MergeRequests::BuildService do @@ -225,6 +224,11 @@ describe MergeRequests::BuildService do let(:label_ids) { [label2.id] } let(:milestone_id) { milestone2.id } + before do + # Guests are not able to assign labels or milestones to an issue + project.add_developer(user) + end + it 'assigns milestone_id and label_ids instead of issue labels and milestone' do expect(merge_request.milestone).to eq(milestone2) expect(merge_request.labels).to match_array([label2]) @@ -479,4 +483,35 @@ describe MergeRequests::BuildService do end end end + + context 'when assigning labels' do + let(:label_ids) { [create(:label, project: project).id] } + + context 'for members with less than developer access' do + it 'is not allowed' do + expect(merge_request.label_ids).to be_empty + end + end + + context 'for users allowed to assign labels' do + before do + project.add_developer(user) + end + + context 'for labels in the project' do + it 'is allowed for developers' do + expect(merge_request.label_ids).to contain_exactly(*label_ids) + end + end + + context 'for unrelated labels' do + let(:project_label) { create(:label, project: project) } + let(:label_ids) { [create(:label).id, project_label.id] } + + it 'only assigns related labels' do + expect(merge_request.label_ids).to contain_exactly(project_label.id) + end + end + end + end end |