adds specs for beta testers

This commit is contained in:
rgarcia
2015-08-29 15:44:13 +02:00
parent d0fa2a3ae6
commit bf0234ff44
2 changed files with 50 additions and 4 deletions

View File

@@ -0,0 +1,37 @@
require 'rails_helper'
feature 'Beta testers' do
background do
allow_any_instance_of(ApplicationController).
to receive(:beta_site?).and_return(true)
allow_any_instance_of(ApplicationController).
to receive(:beta_testers).and_return(['isabel@example.com'])
end
scenario 'Beta testers should have access', :focus do
visit root_path
sign_up('isabel@example.com', 'secretpassword')
confirm_email
fill_in 'user_email', with: 'isabel@example.com'
fill_in 'user_password', with: 'secretpassword'
click_button 'Log in'
expect(page).to have_content "Signed in successfully."
end
scenario 'Non beta testers should not have access', :focus do
visit root_path
sign_up('other@example.com', 'secretpassword')
confirm_email
fill_in 'user_email', with: 'other@example.com'
fill_in 'user_password', with: 'secretpassword'
click_button 'Log in'
expect(page).to have_content "Sorry only Beta Testers are allowed access at the moment"
end
end

View File

@@ -1,18 +1,27 @@
module CommonActions
def sign_up
def sign_up(email='manuela@madrid.es', password='judgementday')
visit '/'
click_link 'Sign up'
fill_in 'user_username', with: 'Manuela Carmena'
fill_in 'user_email', with: 'manuela@madrid.es'
fill_in 'user_password', with: 'judgementday'
fill_in 'user_password_confirmation', with: 'judgementday'
fill_in 'user_email', with: email
fill_in 'user_password', with: password
fill_in 'user_password_confirmation', with: password
fill_in 'user_captcha', with: correct_captcha_text
click_button 'Sign up'
end
def confirm_email
expect(page).to have_content "A message with a confirmation link has been sent to your email address."
sent_token = /.*confirmation_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1]
visit user_confirmation_path(confirmation_token: sent_token)
expect(page).to have_content "Your email address has been successfully confirmed"
end
def reset_password
create(:user, email: 'manuela@madrid.es')