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/customer_relations/contacts/update_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/customer_relations/contacts/update_service_spec.rb')
-rw-r--r-- | spec/services/customer_relations/contacts/update_service_spec.rb | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/spec/services/customer_relations/contacts/update_service_spec.rb b/spec/services/customer_relations/contacts/update_service_spec.rb index 253bbc23226..729fdc2058b 100644 --- a/spec/services/customer_relations/contacts/update_service_spec.rb +++ b/spec/services/customer_relations/contacts/update_service_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe CustomerRelations::Contacts::UpdateService do let_it_be(:user) { create(:user) } - let(:contact) { create(:contact, first_name: 'Mark', group: group) } + let(:contact) { create(:contact, first_name: 'Mark', group: group, state: 'active') } subject(:update) { described_class.new(group: group, current_user: user, params: params).execute(contact) } @@ -19,7 +19,7 @@ RSpec.describe CustomerRelations::Contacts::UpdateService do response = update expect(response).to be_error - expect(response.message).to match_array(['You have insufficient permissions to update a contact for this group']) + expect(response.message).to match_array(['You have insufficient permissions to manage contacts for this group']) end end @@ -41,6 +41,29 @@ RSpec.describe CustomerRelations::Contacts::UpdateService do end end + context 'when activating' do + let(:contact) { create(:contact, state: 'inactive') } + let(:params) { { active: true } } + + it 'updates the contact' do + response = update + + expect(response).to be_success + expect(response.payload.active?).to be_truthy + end + end + + context 'when deactivating' do + let(:params) { { active: false } } + + it 'updates the contact' do + response = update + + expect(response).to be_success + expect(response.payload.active?).to be_falsy + end + end + context 'when the contact is invalid' do let(:params) { { first_name: nil } } |