Only show openid options if providers are set in User model.
This commit is contained in:
parent
609f2fd564
commit
be468be5d7
6 changed files with 32 additions and 25 deletions
|
|
@ -4,15 +4,15 @@ feature Openid do
|
|||
let!(:participant_role) { create(:participant_role) }
|
||||
let!(:admin_role) { create(:admin_role) }
|
||||
|
||||
describe 'sign in with openid' do
|
||||
shared_examples 'sign in with openid' do
|
||||
|
||||
it 'has option to log in with Google account' do
|
||||
scenario 'has option to log in with Google account' do
|
||||
visit '/accounts/sign_in'
|
||||
expect(page.has_content?('Or use your openID')).to be true
|
||||
expect(page.has_content?('google')).to be true
|
||||
end
|
||||
|
||||
it 'signs in *new* user with Google account' do
|
||||
scenario 'signs in *new* user with Google account' do
|
||||
expected_count_openid = Openid.count + 1
|
||||
expected_count_user = User.count + 1
|
||||
visit '/accounts/sign_in'
|
||||
|
|
@ -24,7 +24,7 @@ feature Openid do
|
|||
expect(User.count).to eq(expected_count_user)
|
||||
end
|
||||
|
||||
it 'signs in an existing user' do
|
||||
scenario 'signs in an existing user' do
|
||||
create(:participant, email: 'test-participant-1@google.com')
|
||||
expected_count_openid = Openid.count + 1
|
||||
expected_count_user = User.count
|
||||
|
|
@ -37,7 +37,7 @@ feature Openid do
|
|||
expect(User.count).to eq(expected_count_user)
|
||||
end
|
||||
|
||||
it 'can handle authentication error' do
|
||||
scenario 'can handle authentication error' do
|
||||
OmniAuth.config.mock_auth[:google] = :invalid_credentials
|
||||
visit '/accounts/sign_in'
|
||||
expect(page.has_content?('Or use your openID')).to be true
|
||||
|
|
@ -45,7 +45,7 @@ feature Openid do
|
|||
expect(flash).to eq("Could not authenticate you from Google because \"Invalid credentials\".")
|
||||
end
|
||||
|
||||
it 'adds openid to existing user' do
|
||||
scenario 'adds openid to existing user' do
|
||||
# Sign in user
|
||||
user = create(:participant, email: 'test-participant-1@google.com')
|
||||
sign_in user
|
||||
|
|
@ -63,7 +63,7 @@ feature Openid do
|
|||
expect(Openid.where(email: 'test-1@gmail.com').first.nil?).to eq(false)
|
||||
end
|
||||
|
||||
it 'signs in with openID using the same email as another associated openid' do
|
||||
scenario 'signs in with openID using the same email as another associated openid' do
|
||||
# Sign in user
|
||||
create(:participant, email: 'test-participant-1@google.com')
|
||||
expected_count_openid = Openid.count + 1
|
||||
|
|
@ -105,4 +105,10 @@ feature Openid do
|
|||
expect(last_openid.email).to eq('test-1@gmail.com')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'omniauth' do
|
||||
if User.omniauth_providers.present?
|
||||
it_behaves_like 'sign in with openid'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue