diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/services/users | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/services/users')
-rw-r--r-- | spec/services/users/ban_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/users/dismiss_group_callout_service_spec.rb | 25 | ||||
-rw-r--r-- | spec/services/users/dismiss_user_callout_service_spec.rb | 25 | ||||
-rw-r--r-- | spec/services/users/migrate_to_ghost_user_service_spec.rb | 18 | ||||
-rw-r--r-- | spec/services/users/reject_service_spec.rb | 4 | ||||
-rw-r--r-- | spec/services/users/unban_service_spec.rb | 2 |
6 files changed, 38 insertions, 38 deletions
diff --git a/spec/services/users/ban_service_spec.rb b/spec/services/users/ban_service_spec.rb index 6f49ee08782..79f3cbeb46d 100644 --- a/spec/services/users/ban_service_spec.rb +++ b/spec/services/users/ban_service_spec.rb @@ -50,7 +50,7 @@ RSpec.describe Users::BanService do response = ban_user expect(response[:status]).to eq(:error) - expect(response[:message]).to match(/State cannot transition/) + expect(response[:message]).to match('You cannot ban blocked users.') end it_behaves_like 'does not modify the BannedUser record or user state' diff --git a/spec/services/users/dismiss_group_callout_service_spec.rb b/spec/services/users/dismiss_group_callout_service_spec.rb new file mode 100644 index 00000000000..d74602a7606 --- /dev/null +++ b/spec/services/users/dismiss_group_callout_service_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Users::DismissGroupCalloutService do + describe '#execute' do + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } + + let(:params) { { feature_name: feature_name, group_id: group.id } } + let(:feature_name) { Users::GroupCallout.feature_names.each_key.first } + + subject(:execute) do + described_class.new( + container: nil, current_user: user, params: params + ).execute + end + + it_behaves_like 'dismissing user callout', Users::GroupCallout + + it 'sets the group_id' do + expect(execute.group_id).to eq(group.id) + end + end +end diff --git a/spec/services/users/dismiss_user_callout_service_spec.rb b/spec/services/users/dismiss_user_callout_service_spec.rb index 22f84a939f7..6bf9961eb74 100644 --- a/spec/services/users/dismiss_user_callout_service_spec.rb +++ b/spec/services/users/dismiss_user_callout_service_spec.rb @@ -3,25 +3,18 @@ require 'spec_helper' RSpec.describe Users::DismissUserCalloutService do - let(:user) { create(:user) } - - let(:service) do - described_class.new( - container: nil, current_user: user, params: { feature_name: UserCallout.feature_names.each_key.first } - ) - end - describe '#execute' do - subject(:execute) { service.execute } + let_it_be(:user) { create(:user) } - it 'returns a user callout' do - expect(execute).to be_an_instance_of(UserCallout) - end + let(:params) { { feature_name: feature_name } } + let(:feature_name) { UserCallout.feature_names.each_key.first } - it 'sets the dismisse_at attribute to current time' do - freeze_time do - expect(execute).to have_attributes(dismissed_at: Time.current) - end + subject(:execute) do + described_class.new( + container: nil, current_user: user, params: params + ).execute end + + it_behaves_like 'dismissing user callout', UserCallout end end diff --git a/spec/services/users/migrate_to_ghost_user_service_spec.rb b/spec/services/users/migrate_to_ghost_user_service_spec.rb index c9c8f9a74d3..c36889f20ec 100644 --- a/spec/services/users/migrate_to_ghost_user_service_spec.rb +++ b/spec/services/users/migrate_to_ghost_user_service_spec.rb @@ -92,23 +92,5 @@ RSpec.describe Users::MigrateToGhostUserService do let(:created_record) { create(:review, author: user) } end end - - context "when record migration fails with a rollback exception" do - before do - expect_any_instance_of(ActiveRecord::Associations::CollectionProxy) - .to receive(:update_all).and_raise(ActiveRecord::Rollback) - end - - context "for records that were already migrated" do - let!(:issue) { create(:issue, project: project, author: user) } - let!(:merge_request) { create(:merge_request, source_project: project, author: user, target_branch: "first") } - - it "reverses the migration" do - service.execute - - expect(issue.reload.author).to eq(user) - end - end - end end end diff --git a/spec/services/users/reject_service_spec.rb b/spec/services/users/reject_service_spec.rb index b0094a7c47e..5a243e876ac 100644 --- a/spec/services/users/reject_service_spec.rb +++ b/spec/services/users/reject_service_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Users::RejectService do it 'returns error result' do expect(subject[:status]).to eq(:error) expect(subject[:message]) - .to match(/This user does not have a pending request/) + .to match(/User does not have a pending request/) end end end @@ -44,7 +44,7 @@ RSpec.describe Users::RejectService do it 'emails the user on rejection' do expect_next_instance_of(NotificationService) do |notification| - allow(notification).to receive(:user_admin_rejection).with(user.name, user.notification_email) + allow(notification).to receive(:user_admin_rejection).with(user.name, user.notification_email_or_default) end subject diff --git a/spec/services/users/unban_service_spec.rb b/spec/services/users/unban_service_spec.rb index b2b3140ccb3..d536baafdcc 100644 --- a/spec/services/users/unban_service_spec.rb +++ b/spec/services/users/unban_service_spec.rb @@ -50,7 +50,7 @@ RSpec.describe Users::UnbanService do response = unban_user expect(response[:status]).to eq(:error) - expect(response[:message]).to match(/State cannot transition/) + expect(response[:message]).to match('You cannot unban active users.') end it_behaves_like 'does not modify the BannedUser record or user state' |