|
|
@ -39,16 +39,33 @@ describe 'OmniAuth callbacks' do
|
|
|
|
Fabricate(:user, email: 'user@host.example')
|
|
|
|
Fabricate(:user, email: 'user@host.example')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'matches the existing user, creates an identity, and redirects to root path' do
|
|
|
|
context 'when ALLOW_UNSAFE_AUTH_PROVIDER_REATTACH is set to true' do
|
|
|
|
expect { subject }
|
|
|
|
around do |example|
|
|
|
|
.to not_change(User, :count)
|
|
|
|
ClimateControl.modify ALLOW_UNSAFE_AUTH_PROVIDER_REATTACH: 'true' do
|
|
|
|
.and change(Identity, :count)
|
|
|
|
example.run
|
|
|
|
.by(1)
|
|
|
|
end
|
|
|
|
.and change(LoginActivity, :count)
|
|
|
|
end
|
|
|
|
.by(1)
|
|
|
|
|
|
|
|
|
|
|
|
it 'matches the existing user, creates an identity, and redirects to root path' do
|
|
|
|
|
|
|
|
expect { subject }
|
|
|
|
|
|
|
|
.to not_change(User, :count)
|
|
|
|
|
|
|
|
.and change(Identity, :count)
|
|
|
|
|
|
|
|
.by(1)
|
|
|
|
|
|
|
|
.and change(LoginActivity, :count)
|
|
|
|
|
|
|
|
.by(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(Identity.find_by(user: User.last).uid).to eq('123')
|
|
|
|
|
|
|
|
expect(response).to redirect_to(root_path)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
expect(Identity.find_by(user: User.last).uid).to eq('123')
|
|
|
|
context 'when ALLOW_UNSAFE_AUTH_PROVIDER_REATTACH is not set to true' do
|
|
|
|
expect(response).to redirect_to(root_path)
|
|
|
|
it 'does not match the existing user or create an identity' do
|
|
|
|
|
|
|
|
expect { subject }
|
|
|
|
|
|
|
|
.to not_change(User, :count)
|
|
|
|
|
|
|
|
.and not_change(Identity, :count)
|
|
|
|
|
|
|
|
.and not_change(LoginActivity, :count)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|