diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/services/quick_actions/interpret_service_spec.rb | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) | |
download | gitlab-ce-aee0a117a889461ce8ced6fcf73207fe017f1d99.tar.gz |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/services/quick_actions/interpret_service_spec.rb')
-rw-r--r-- | spec/services/quick_actions/interpret_service_spec.rb | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 611261cd92c..77d263f4b70 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper' RSpec.describe QuickActions::InterpretService do - let_it_be(:public_project) { create(:project, :public) } + let_it_be(:group) { create(:group) } + let_it_be(:public_project) { create(:project, :public, group: group) } let_it_be(:repository_project) { create(:project, :repository) } let_it_be(:project) { public_project } let_it_be(:developer) { create(:user) } @@ -2233,6 +2234,51 @@ RSpec.describe QuickActions::InterpretService do end end end + + context 'crm_contact commands' do + let_it_be(:new_contact) { create(:contact, group: group) } + let_it_be(:existing_contact) { create(:contact, group: group) } + + let(:add_command) { service.execute("/add_contacts #{new_contact.email}", issue) } + let(:remove_command) { service.execute("/remove_contacts #{existing_contact.email}", issue) } + + before do + issue.project.group.add_developer(developer) + create(:issue_customer_relations_contact, issue: issue, contact: existing_contact) + end + + context 'with feature flag disabled' do + before do + stub_feature_flags(customer_relations: false) + end + + it 'add_contacts command does not add the contact' do + _, updates, _ = add_command + + expect(updates).to be_empty + end + + it 'remove_contacts command does not remove the contact' do + _, updates, _ = remove_command + + expect(updates).to be_empty + end + end + + it 'add_contacts command adds the contact' do + _, updates, message = add_command + + expect(updates).to eq(add_contacts: [new_contact.email]) + expect(message).to eq('One or more contacts were successfully added.') + end + + it 'remove_contacts command removes the contact' do + _, updates, message = remove_command + + expect(updates).to eq(remove_contacts: [existing_contact.email]) + expect(message).to eq('One or more contacts were successfully removed.') + end + end end describe '#explain' do |