Refactors confirm_email & uses it in user_auth_spec

This commit is contained in:
kikito
2016-01-18 17:32:27 +01:00
parent b71dd5767b
commit 91a16142bf
2 changed files with 7 additions and 8 deletions

View File

@@ -18,8 +18,7 @@ feature 'Users' do
expect(page).to have_content "You have been sent a message containing a verification link. Please click on this link to activate your account."
sent_token = /.*confirmation_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1]
visit user_confirmation_path(confirmation_token: sent_token)
confirm_email
expect(page).to have_content "Your account has been confirmed."
end
@@ -124,8 +123,7 @@ feature 'Users' do
fill_in 'user_email', with: 'manueladelascarmenas@example.com'
click_button 'Register'
sent_token = /.*confirmation_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1]
visit user_confirmation_path(confirmation_token: sent_token)
confirm_email
expect(page).to have_content "Your email address has been successfully confirmed"
@@ -134,7 +132,7 @@ feature 'Users' do
scenario 'Sign in, user was already signed up with OAuth' do
user = create(:user, email: 'manuela@madrid.es', password: 'judgementday')
identity = create(:identity, uid: '12345', provider: 'twitter', user: user)
create(:identity, uid: '12345', provider: 'twitter', user: user)
omniauth_twitter_hash = { 'provider' => 'twitter',
'uid' => '12345',
'info' => {

View File

@@ -36,12 +36,13 @@ module CommonActions
end
def confirm_email
expect(page).to have_content "A message with a confirmation link has been sent to your email address."
body = ActionMailer::Base.deliveries.last.try(:body)
expect(body).to be_present
sent_token = /.*confirmation_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1]
sent_token = /.*confirmation_token=(.*)".*/.match(body.to_s)[1]
visit user_confirmation_path(confirmation_token: sent_token)
expect(page).to have_content "Your email address has been successfully confirmed"
expect(page).to have_content "Your account has been confirmed"
end
def reset_password