diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-13 16:26:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-13 16:26:31 +0300 |
commit | b7dfe2ae4054aa40e15182fd3c6cb7dd39f131db (patch) | |
tree | 5ab080ca9cadeb6cd9578bf301e4e9e8810bed9e /spec/serializers/issue_entity_spec.rb | |
parent | 25cb337cf12438169f1b14bc5dace8a06a7356e3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/issue_entity_spec.rb')
-rw-r--r-- | spec/serializers/issue_entity_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/serializers/issue_entity_spec.rb b/spec/serializers/issue_entity_spec.rb index 0e05b3c84f4..53278062de9 100644 --- a/spec/serializers/issue_entity_spec.rb +++ b/spec/serializers/issue_entity_spec.rb @@ -50,4 +50,44 @@ describe IssueEntity do end end end + + context 'when issue got duplicated' do + let(:private_project) { create(:project, :private) } + let(:member) { create(:user) } + let(:issue) { create(:issue, project: project) } + let(:new_issue) { create(:issue, project: private_project) } + + before do + Issues::DuplicateService + .new(project, member) + .execute(issue, new_issue) + end + + context 'when user cannot read new issue' do + let(:non_member) { create(:user) } + + it 'does not return duplicated_to_id' do + request = double('request', current_user: non_member) + + response = described_class.new(issue, request: request).as_json + + expect(response[:duplicated_to_id]).to be_nil + end + end + + context 'when user can read target project' do + before do + project.add_developer(member) + private_project.add_developer(member) + end + + it 'returns duplicated duplicated_to_id' do + request = double('request', current_user: member) + + response = described_class.new(issue, request: request).as_json + + expect(response[:duplicated_to_id]).to eq(issue.duplicated_to_id) + end + end + end end |