diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/services/issues/set_crm_contacts_service_spec.rb | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/services/issues/set_crm_contacts_service_spec.rb')
-rw-r--r-- | spec/services/issues/set_crm_contacts_service_spec.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/services/issues/set_crm_contacts_service_spec.rb b/spec/services/issues/set_crm_contacts_service_spec.rb index b0befb9f77c..5613cc49cc5 100644 --- a/spec/services/issues/set_crm_contacts_service_spec.rb +++ b/spec/services/issues/set_crm_contacts_service_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe Issues::SetCrmContactsService do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group, :crm_enabled) } - let_it_be(:project) { create(:project, group: create(:group, parent: group)) } + let_it_be(:project) { create(:project, group: create(:group, :crm_enabled, parent: group)) } let_it_be(:contacts) { create_list(:contact, 4, group: group) } let_it_be(:issue, reload: true) { create(:issue, project: project) } let_it_be(:issue_contact_1) do @@ -58,6 +58,20 @@ RSpec.describe Issues::SetCrmContactsService do group.add_reporter(user) end + context 'but the crm setting is disabled' do + let(:params) { { replace_ids: [contacts[1].id, contacts[2].id] } } + let(:subgroup_with_crm_disabled) { create(:group, parent: group) } + let(:project_with_crm_disabled) { create(:project, group: subgroup_with_crm_disabled) } + let(:issue_with_crm_disabled) { create(:issue, project: project_with_crm_disabled) } + + it 'returns expected error response' do + response = described_class.new(project: project_with_crm_disabled, current_user: user, params: params).execute(issue_with_crm_disabled) + + expect(response).to be_error + expect(response.message).to eq('You have insufficient permissions to set customer relations contacts for this issue') + end + end + context 'when the contact does not exist' do let(:params) { { replace_ids: [non_existing_record_id] } } |