diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0b10efcf..1cea13948 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,9 @@ jobs: DATABASE_URL: postgres://postgres:password@localhost:5432/test DOMAIN: recovery.app BOT_TOKEN: bot_token + GOV_ONE_BASE_URI: https://oidc.test.account.gov.uk + GOV_ONE_REDIRECT_URI: https://recovery.app/users/auth/openid_connect/callback + GOV_ONE_LOGOUT_REDIRECT_URI: https://recovery.app/users/sign_out services: postgres: diff --git a/app/models/user.rb b/app/models/user.rb index d05fad376..711c392a3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,16 +25,14 @@ def self.dashboard_headers # @param gov_one_id [String] # @return [User] def self.find_or_create_from_gov_one(email:, gov_one_id:) - existing_user = find_by(email: email) || find_by(gov_one_id: gov_one_id) - - if existing_user - existing_user.update!(email: email) - existing_user.update!(gov_one_id: gov_one_id) if existing_user.gov_one_id.nil? + if (user = find_by(email: email) || find_by(gov_one_id: gov_one_id)) + user.update!(email: email) + user.update!(gov_one_id: gov_one_id) if user.gov_one_id.nil? else - existing_user = new(email: email, gov_one_id: gov_one_id, confirmed_at: Time.zone.now) - existing_user.save!(validate: false) + user = new(email: email, gov_one_id: gov_one_id, confirmed_at: Time.zone.now) + user.save!(validate: false) end - existing_user + user end # Include default devise modules. Others available are: diff --git a/spec/helpers/gov_one_helper_spec.rb b/spec/helpers/gov_one_helper_spec.rb index 196178d2f..27994974d 100644 --- a/spec/helpers/gov_one_helper_spec.rb +++ b/spec/helpers/gov_one_helper_spec.rb @@ -1,7 +1,6 @@ require 'rails_helper' describe 'GovOneHelper', type: :helper do - describe '#login_uri' do subject(:login_uri) { helper.login_uri }