summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2017-06-16 15:14:46 +0200
committerJames Lopez <james@jameslopez.es>2017-06-23 11:41:42 +0200
commitad44af2faaaa872ee30922699f66ac78fa402336 (patch)
treee264d9bf4e57dc3468281167374da3f53e7ebe57
parent7aaf3692b3856fa4d11bfc51ef4ab18c7405fc06 (diff)
downloadgitlab-ce-ad44af2faaaa872ee30922699f66ac78fa402336.tar.gz
fixed specs
-rw-r--r--lib/api/users.rb2
-rw-r--r--spec/services/emails/create_service_spec.rb2
-rw-r--r--spec/services/emails/destroy_service_spec.rb6
3 files changed, 6 insertions, 4 deletions
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 2c632c85243..f79b61ad85e 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -511,7 +511,7 @@ module API
not_found!('Email') unless email
email.destroy
- ::Users::UpdateService.new(current_user, user).execute do |user|
+ ::Users::UpdateService.new(current_user, current_user).execute do |user|
user.update_secondary_emails!
end
end
diff --git a/spec/services/emails/create_service_spec.rb b/spec/services/emails/create_service_spec.rb
index 7874da88665..9981f5fcc2b 100644
--- a/spec/services/emails/create_service_spec.rb
+++ b/spec/services/emails/create_service_spec.rb
@@ -19,7 +19,7 @@ describe Emails::CreateService, services: true do
end
it 'does not create an email if the user has no permissions' do
- expect { described_class.new(create(:user), user, opts).execute }.not_to change { Email.count }
+ expect { described_class.new(create(:user), user, opts).execute }.to raise_error(Gitlab::Access::AccessDeniedError)
end
it 'creates an email if we skip authorization' do
diff --git a/spec/services/emails/destroy_service_spec.rb b/spec/services/emails/destroy_service_spec.rb
index 186726951f9..6db050148cb 100644
--- a/spec/services/emails/destroy_service_spec.rb
+++ b/spec/services/emails/destroy_service_spec.rb
@@ -12,12 +12,14 @@ describe Emails::DestroyService, services: true do
end
it 'does not remove an email if the user has no permissions' do
- expect { described_class.new(create(:user), user, opts).execute }.not_to change { Email.count }
+ expect do
+ described_class.new(create(:user), user, email: email.email).execute
+ end.to raise_error(Gitlab::Access::AccessDeniedError)
end
it 'removes an email if we skip authorization' do
expect do
- described_class.new(create(:user), user, opts).execute(skip_authorization: true)
+ described_class.new(create(:user), user, email: email.email).execute(skip_authorization: true)
end.to change { Email.count }.by(-1)
end
end