Adds two new scenarios to auth specs

This commit is contained in:
kikito
2016-01-20 18:15:14 +01:00
parent 9318cd8d7e
commit 892612fe9b

View File

@@ -132,6 +132,63 @@ feature 'Users' do
expect_to_be_signed_in
end
scenario 'Try to register with the username of an already existing user' do
create(:user, username: 'manuela', email: 'manuela@madrid.es', password: 'judgementday')
OmniAuth.config.add_mock(:twitter, twitter_hash_with_email)
visit '/'
click_link 'Register'
click_link 'Sign up with Twitter'
expect(current_path).to eq(finish_signup_path)
fill_in 'user_username', with: 'manuela2'
click_button 'Register'
expect_to_be_signed_in
click_link 'My account'
expect(page).to have_field('account_username', with: 'manuela2')
visit edit_user_registration_path
expect(page).to have_field('user_email', with: 'manuelacarmena@example.com')
end
scenario 'Try to register with the email of an already existing user' do
create(:user, username: 'peter', email: 'manuela@example.com')
OmniAuth.config.add_mock(:twitter, twitter_hash)
visit '/'
click_link 'Register'
click_link 'Sign up with Twitter'
expect(current_path).to eq(finish_signup_path)
fill_in 'user_email', with: 'manuela@example.com'
click_button 'Register'
expect(current_path).to eq(do_finish_signup_path)
fill_in 'user_email', with: 'somethingelse@example.com'
click_button 'Register'
expect(page).to have_content "You must confirm your account to continue"
confirm_email
expect(page).to have_content "Your account has been confirmed"
visit '/'
click_link 'Sign in'
click_link 'Sign in with Twitter'
expect_to_be_signed_in
click_link 'My account'
expect(page).to have_field('account_username', with: 'manuela')
visit edit_user_registration_path
expect(page).to have_field('user_email', with: 'somethingelse@example.com')
end
end
end