Commit e0d6ba0c authored by charlie ablett's avatar charlie ablett

Merge branch...

Merge branch '300913-refactor-group_sso-and-group_managed_account-entity-properties-to-use-presenter' into 'master'

Refactor member entity properties to use presenter

See merge request gitlab-org/gitlab!53276
parents 7a75ec47 019ba282
......@@ -5,10 +5,14 @@ module EE
extend ::Gitlab::Utils::Override
def group_sso?
return false unless member.user.present?
member.user.group_sso?(source)
end
def group_managed_account?
return false unless member.user.present?
member.user.group_managed_account?
end
......
......@@ -9,13 +9,9 @@ module EE
can?(current_user, :owner_access, group) && member.user&.using_gitlab_com_seat?(group)
end
expose :group_sso do |member|
member.user&.group_sso?(group)
end
expose :group_sso?, as: :group_sso
expose :group_managed_account do |member|
member.user&.group_managed_account?
end
expose :group_managed_account?, as: :group_managed_account
expose :can_override do |member|
member.can_override?
......
......@@ -12,6 +12,14 @@ RSpec.describe GroupMemberPresenter do
let(:saml_provider) { double(:saml_provider) }
let(:group) { double(:group) }
context 'when member does not have a user (invited member)' do
let(:group_member) { build(:group_member, :invited) }
it 'returns `false`' do
expect(presenter.group_sso?).to eq false
end
end
it 'calls through to User#group_sso?' do
expect(user).to receive(:group_sso?).with(group).and_return(true)
......@@ -20,6 +28,14 @@ RSpec.describe GroupMemberPresenter do
end
describe '#group_managed_account?' do
context 'when member does not have a user (invited member)' do
let(:group_member) { build(:group_member, :invited) }
it 'returns `false`' do
expect(presenter.group_managed_account?).to eq false
end
end
context 'when user is part of the group managed account' do
before do
expect(user).to receive(:group_managed_account?).and_return(true)
......
......@@ -20,13 +20,13 @@ RSpec.describe MemberEntity do
end
it 'correctly exposes `group_sso`' do
allow(member.user).to receive(:group_sso?).with(group).and_return(true)
allow(member).to receive(:group_sso?).and_return(true)
expect(entity_hash[:group_sso]).to be(true)
end
it 'correctly exposes `group_managed_account`' do
allow(member.user).to receive(:group_managed_account?).and_return(true)
allow(member).to receive(:group_managed_account?).and_return(true)
expect(entity_hash[:group_managed_account]).to be(true)
end
......
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