Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/customer_relations/contacts/update_service_spec.rb')
-rw-r--r--spec/services/customer_relations/contacts/update_service_spec.rb27
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 } }