diff --git a/enterprise/app/builders/saml_user_builder.rb b/enterprise/app/builders/saml_user_builder.rb index 411d951f3..bd0059d07 100644 --- a/enterprise/app/builders/saml_user_builder.rb +++ b/enterprise/app/builders/saml_user_builder.rb @@ -1,13 +1,13 @@ class SamlUserBuilder - def initialize(auth_hash, account_id: nil) + def initialize(auth_hash, account_id) @auth_hash = auth_hash @account_id = account_id - @saml_settings = AccountSamlSettings.find_by(account_id: account_id) if account_id + @saml_settings = AccountSamlSettings.find_by(account_id: account_id) end def perform @user = find_or_create_user - add_user_to_account if @user.persisted? && @account_id + add_user_to_account if @user.persisted? @user end diff --git a/enterprise/app/controllers/enterprise/devise_overrides/omniauth_callbacks_controller.rb b/enterprise/app/controllers/enterprise/devise_overrides/omniauth_callbacks_controller.rb index bb4edfbfa..91f05c406 100644 --- a/enterprise/app/controllers/enterprise/devise_overrides/omniauth_callbacks_controller.rb +++ b/enterprise/app/controllers/enterprise/devise_overrides/omniauth_callbacks_controller.rb @@ -41,7 +41,7 @@ module Enterprise::DeviseOverrides::OmniauthCallbacksController account_id = extract_saml_account_id return redirect_to login_page_url(error: 'saml-not-enabled') unless saml_enabled_for_account?(account_id) - @resource = SamlUserBuilder.new(auth_hash, account_id: account_id).perform + @resource = SamlUserBuilder.new(auth_hash, account_id).perform if @resource.persisted? sign_in_user diff --git a/spec/enterprise/builders/saml_user_builder_spec.rb b/spec/enterprise/builders/saml_user_builder_spec.rb index 42bfc77f3..e677737a3 100644 --- a/spec/enterprise/builders/saml_user_builder_spec.rb +++ b/spec/enterprise/builders/saml_user_builder_spec.rb @@ -20,7 +20,7 @@ RSpec.describe SamlUserBuilder do } end let(:account) { create(:account) } - let(:builder) { described_class.new(auth_hash, account_id: account.id) } + let(:builder) { described_class.new(auth_hash, account.id) } describe '#perform' do context 'when user does not exist' do @@ -111,16 +111,6 @@ RSpec.describe SamlUserBuilder do end end - context 'without account_id' do - let(:builder) { described_class.new(auth_hash) } - - it 'creates user without account association' do - user = builder.perform - expect(user.persisted?).to be true - expect(user.accounts).to be_empty - end - end - context 'with role mappings' do let!(:saml_settings) do create(:account_saml_settings,