summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 15:09:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 15:09:30 +0000
commitc6b3ec3f56fa32a0e0ed3de0d0878d25f1adaddf (patch)
tree967afee9a510ff9dd503ebd83706dc760ec2e3ed /spec/models/user_spec.rb
parent903ccf7c93eb9490c76857bffe744249cc07de09 (diff)
downloadgitlab-ce-c6b3ec3f56fa32a0e0ed3de0d0878d25f1adaddf.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb34
1 files changed, 20 insertions, 14 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 679f4a19f5b..5a3e16baa87 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -5,6 +5,7 @@ require 'spec_helper'
describe User, :do_not_mock_admin_mode do
include ProjectForksHelper
include TermsHelper
+ include ExclusiveLeaseHelpers
it_behaves_like 'having unique enum values'
@@ -4535,17 +4536,22 @@ describe User, :do_not_mock_admin_mode do
context 'when after_commit :update_highest_role' do
describe 'create user' do
- it 'initializes a new Members::UpdateHighestRoleService object' do
- expect_next_instance_of(Members::UpdateHighestRoleService) do |service|
- expect(service).to receive(:execute)
+ subject { create(:user) }
+
+ it 'schedules a job in the future', :aggregate_failures, :clean_gitlab_redis_shared_state do
+ allow_next_instance_of(Gitlab::ExclusiveLease) do |instance|
+ allow(instance).to receive(:try_obtain).and_return('uuid')
end
- create(:user)
+ expect(UpdateHighestRoleWorker).to receive(:perform_in).and_call_original
+
+ expect { subject }.to change(UpdateHighestRoleWorker.jobs, :size).by(1)
end
end
context 'when user already exists' do
let!(:user) { create(:user) }
+ let(:user_id) { user.id }
describe 'update user' do
using RSpec::Parameterized::TableSyntax
@@ -4560,24 +4566,24 @@ describe User, :do_not_mock_admin_mode do
with_them do
context 'when state was changed' do
- it 'initializes a new Members::UpdateHighestRoleService object' do
- expect_next_instance_of(Members::UpdateHighestRoleService) do |service|
- expect(service).to receive(:execute)
- end
+ subject { user.update(attributes) }
- user.update(attributes)
- end
+ include_examples 'update highest role with exclusive lease'
end
end
context 'when state was not changed' do
- it 'does not initialize a new Members::UpdateHighestRoleService object' do
- expect(Members::UpdateHighestRoleService).not_to receive(:new)
+ subject { user.update(email: 'newmail@example.com') }
- user.update(email: 'newmail@example.com')
- end
+ include_examples 'does not update the highest role'
end
end
+
+ describe 'destroy user' do
+ subject { user.destroy }
+
+ include_examples 'does not update the highest role'
+ end
end
end