Commit 91f1fc4f authored by Patrick Bajao's avatar Patrick Bajao

Merge branch 'id-members-destroy-service-kwargs' into 'master'

Fix Ruby 2.7 deprecation warnings for Members::DestroyService

See merge request gitlab-org/gitlab!43524
parents 8b3e261b 6e7978db
...@@ -5,7 +5,7 @@ class NotificationRecipient ...@@ -5,7 +5,7 @@ class NotificationRecipient
attr_reader :user, :type, :reason attr_reader :user, :type, :reason
def initialize(user, type, **opts) def initialize(user, type, opts = {})
unless NotificationSetting.levels.key?(type) || type == :subscription unless NotificationSetting.levels.key?(type) || type == :subscription
raise ArgumentError, "invalid type: #{type.inspect}" raise ArgumentError, "invalid type: #{type.inspect}"
end end
......
...@@ -21,7 +21,7 @@ class UserInteractedProject < ApplicationRecord ...@@ -21,7 +21,7 @@ class UserInteractedProject < ApplicationRecord
user_id: event.author_id user_id: event.author_id
} }
cached_exists?(attributes) do cached_exists?(**attributes) do
transaction(requires_new: true) do transaction(requires_new: true) do
where(attributes).select(1).first || create!(attributes) where(attributes).select(1).first || create!(attributes)
true # not caching the whole record here for now true # not caching the whole record here for now
......
...@@ -31,7 +31,7 @@ RSpec.describe Members::DestroyService do ...@@ -31,7 +31,7 @@ RSpec.describe Members::DestroyService do
end end
it 'cleans up linked SAML identity' do it 'cleans up linked SAML identity' do
expect { subject.execute(member, {}) }.to change { member_user.reload.identities.count }.by(-1) expect { subject.execute(member) }.to change { member_user.reload.identities.count }.by(-1)
end end
end end
...@@ -39,14 +39,14 @@ RSpec.describe Members::DestroyService do ...@@ -39,14 +39,14 @@ RSpec.describe Members::DestroyService do
it 'does not attempt to destroy unrelated identities' do it 'does not attempt to destroy unrelated identities' do
create(:identity, user: member_user) create(:identity, user: member_user)
expect { subject.execute(member, {}) }.not_to change(Identity, :count) expect { subject.execute(member) }.not_to change(Identity, :count)
end end
end end
end end
context 'audit events' do context 'audit events' do
it_behaves_like 'logs an audit event' do it_behaves_like 'logs an audit event' do
let(:event) { subject.execute(member, {}) } let(:event) { subject.execute(member) }
end end
it 'does not log the audit event as a system event' do it 'does not log the audit event as a system event' do
......
...@@ -29,15 +29,15 @@ RSpec.describe Members::DestroyService do ...@@ -29,15 +29,15 @@ RSpec.describe Members::DestroyService do
end end
it 'destroys the member' do it 'destroys the member' do
expect { described_class.new(current_user).execute(member, opts) }.to change { member.source.members_and_requesters.count }.by(-1) expect { described_class.new(current_user).execute(member, **opts) }.to change { member.source.members_and_requesters.count }.by(-1)
end end
it 'destroys member notification_settings' do it 'destroys member notification_settings' do
if member_user.notification_settings.any? if member_user.notification_settings.any?
expect { described_class.new(current_user).execute(member, opts) } expect { described_class.new(current_user).execute(member, **opts) }
.to change { member_user.notification_settings.count }.by(-1) .to change { member_user.notification_settings.count }.by(-1)
else else
expect { described_class.new(current_user).execute(member, opts) } expect { described_class.new(current_user).execute(member, **opts) }
.not_to change { member_user.notification_settings.count } .not_to change { member_user.notification_settings.count }
end end
end end
...@@ -63,7 +63,7 @@ RSpec.describe Members::DestroyService do ...@@ -63,7 +63,7 @@ RSpec.describe Members::DestroyService do
expect(service).to receive(:enqueue_unassign_issuables).with(member) expect(service).to receive(:enqueue_unassign_issuables).with(member)
end end
service.execute(member, opts) service.execute(member, **opts)
expect(member_user.assigned_open_merge_requests_count).to be(0) expect(member_user.assigned_open_merge_requests_count).to be(0)
expect(member_user.assigned_open_issues_count).to be(0) expect(member_user.assigned_open_issues_count).to be(0)
...@@ -83,14 +83,14 @@ RSpec.describe Members::DestroyService do ...@@ -83,14 +83,14 @@ RSpec.describe Members::DestroyService do
it 'calls Member#after_decline_request' do it 'calls Member#after_decline_request' do
expect_any_instance_of(NotificationService).to receive(:decline_access_request).with(member) expect_any_instance_of(NotificationService).to receive(:decline_access_request).with(member)
described_class.new(current_user).execute(member, opts) described_class.new(current_user).execute(member, **opts)
end end
context 'when current user is the member' do context 'when current user is the member' do
it 'does not call Member#after_decline_request' do it 'does not call Member#after_decline_request' do
expect_any_instance_of(NotificationService).not_to receive(:decline_access_request).with(member) expect_any_instance_of(NotificationService).not_to receive(:decline_access_request).with(member)
described_class.new(member_user).execute(member, opts) described_class.new(member_user).execute(member, **opts)
end end
end end
end end
...@@ -280,7 +280,6 @@ RSpec.describe Members::DestroyService do ...@@ -280,7 +280,6 @@ RSpec.describe Members::DestroyService do
context 'subresources' do context 'subresources' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:member_user) { create(:user) } let(:member_user) { create(:user) }
let(:opts) { {} }
let(:group) { create(:group, :public) } let(:group) { create(:group, :public) }
let(:subgroup) { create(:group, parent: group) } let(:subgroup) { create(:group, parent: group) }
...@@ -303,7 +302,7 @@ RSpec.describe Members::DestroyService do ...@@ -303,7 +302,7 @@ RSpec.describe Members::DestroyService do
group_member = create(:group_member, :developer, group: group, user: member_user) group_member = create(:group_member, :developer, group: group, user: member_user)
described_class.new(user).execute(group_member, opts) described_class.new(user).execute(group_member)
end end
it 'removes the project membership' do it 'removes the project membership' do
...@@ -350,7 +349,6 @@ RSpec.describe Members::DestroyService do ...@@ -350,7 +349,6 @@ RSpec.describe Members::DestroyService do
context 'deletion of invitations created by deleted project member' do context 'deletion of invitations created by deleted project member' do
let(:user) { project.owner } let(:user) { project.owner }
let(:member_user) { create(:user) } let(:member_user) { create(:user) }
let(:opts) { {} }
let(:project) { create(:project) } let(:project) { create(:project) }
...@@ -359,7 +357,7 @@ RSpec.describe Members::DestroyService do ...@@ -359,7 +357,7 @@ RSpec.describe Members::DestroyService do
project_member = create(:project_member, :maintainer, user: member_user, project: project) project_member = create(:project_member, :maintainer, user: member_user, project: project)
described_class.new(user).execute(project_member, opts) described_class.new(user).execute(project_member)
end end
it 'removes project members invited by deleted user' do it 'removes project members invited by deleted user' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment