diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-12-14 19:39:53 -0200 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-12-27 19:25:17 -0200 |
commit | 1b082a4c338d7575e15d7450906801db59873441 (patch) | |
tree | 1b5081ce55b63436082b038f499a8c54172fc75a /spec/support/services/issuable_create_service_shared_examples.rb | |
parent | 77deeb12f74b857f9356168ccdf92612fc85fe84 (diff) | |
download | gitlab-ce-1b082a4c338d7575e15d7450906801db59873441.tar.gz |
Check if user can read issue before being assignedissue_22664
Diffstat (limited to 'spec/support/services/issuable_create_service_shared_examples.rb')
-rw-r--r-- | spec/support/services/issuable_create_service_shared_examples.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/support/services/issuable_create_service_shared_examples.rb b/spec/support/services/issuable_create_service_shared_examples.rb new file mode 100644 index 00000000000..93c0267d2db --- /dev/null +++ b/spec/support/services/issuable_create_service_shared_examples.rb @@ -0,0 +1,52 @@ +shared_examples 'issuable create service' do + context 'asssignee_id' do + let(:assignee) { create(:user) } + + before { project.team << [user, :master] } + + it 'removes assignee_id when user id is invalid' do + opts = { title: 'Title', description: 'Description', assignee_id: -1 } + + issuable = described_class.new(project, user, opts).execute + + expect(issuable.assignee_id).to be_nil + end + + it 'removes assignee_id when user id is 0' do + opts = { title: 'Title', description: 'Description', assignee_id: 0 } + + issuable = described_class.new(project, user, opts).execute + + expect(issuable.assignee_id).to be_nil + end + + it 'saves assignee when user id is valid' do + project.team << [assignee, :master] + opts = { title: 'Title', description: 'Description', assignee_id: assignee.id } + + issuable = described_class.new(project, user, opts).execute + + expect(issuable.assignee_id).to eq(assignee.id) + end + + context "when issuable feature is private" do + before do + project.project_feature.update(issues_access_level: ProjectFeature::PRIVATE) + project.project_feature.update(merge_requests_access_level: ProjectFeature::PRIVATE) + end + + levels = [Gitlab::VisibilityLevel::INTERNAL, Gitlab::VisibilityLevel::PUBLIC] + + levels.each do |level| + it "removes not authorized assignee when project is #{Gitlab::VisibilityLevel.level_name(level)}" do + project.update(visibility_level: level) + opts = { title: 'Title', description: 'Description', assignee_id: assignee.id } + + issuable = described_class.new(project, user, opts).execute + + expect(issuable.assignee_id).to be_nil + end + end + end + end +end |