Commit be318259 authored by James Edwards-Jones's avatar James Edwards-Jones

Add :group_saml_identity factory to avoid CE trait

Changes to the :group_saml trait were previously breaking
the ee-specific-lines check.
parent d76f637e
# frozen_string_literal: true
FactoryBot.define do
factory :group_saml_identity, class: Identity, parent: :identity do
provider 'group_saml'
extern_uid { generate(:username) }
saml_provider
user
end
end
......@@ -6,7 +6,7 @@ describe GroupSamlIdentityFinder do
include Gitlab::Routing
let(:user) { create(:user) }
let!(:identity) { create(:identity, :group_saml, user: user) }
let!(:identity) { create(:group_saml_identity, user: user) }
let(:group) { identity.saml_provider.group }
subject { described_class.new(user: user) }
......
......@@ -14,12 +14,12 @@ describe EE::MembersPreloader do
it 'preloads SAML identities to avoid N+1 queries in MembersPresenter' do
member = create(:group_member, group: group)
create(:identity, :group_saml, user: member.user, saml_provider: saml_provider)
create(:group_saml_identity, user: member.user, saml_provider: saml_provider)
control = ActiveRecord::QueryRecorder.new { group_sso_with_preload([member]) }
members = create_list(:group_member, 3, group: group)
create(:identity, :group_saml, user: members.first.user, saml_provider: saml_provider)
create(:identity, :group_saml, user: members.last.user, saml_provider: saml_provider)
create(:group_saml_identity, user: members.first.user, saml_provider: saml_provider)
create(:group_saml_identity, user: members.last.user, saml_provider: saml_provider)
expect { group_sso_with_preload(members) }.not_to exceed_query_limit(control)
end
......
......@@ -257,7 +257,7 @@ describe EE::User do
end
context 'with linked identity' do
let!(:identity) { create(:identity, :group_saml, user: user) }
let!(:identity) { create(:group_saml_identity, user: user) }
let(:saml_provider) { identity.saml_provider }
let(:group) { saml_provider.group }
......@@ -267,7 +267,7 @@ describe EE::User do
end
it 'does not cause ActiveRecord to loop through identites' do
create(:identity, :group_saml, user: user)
create(:group_saml_identity, user: user)
expect(Identity).not_to receive(:instantiate)
......
......@@ -3,7 +3,7 @@
require 'spec_helper'
describe GroupSaml::Identity::DestroyService do
let(:identity) { create(:identity, :group_saml) }
let(:identity) { create(:group_saml_identity) }
subject { described_class.new(identity) }
......
......@@ -2,12 +2,5 @@ FactoryBot.define do
factory :identity do
provider 'ldapmain'
extern_uid 'my-ldap-id'
trait :group_saml do
provider 'group_saml'
extern_uid { generate(:username) }
saml_provider
user
end
end
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