diff --git a/spec/features/beta_testers_spec.rb b/spec/features/beta_testers_spec.rb new file mode 100644 index 000000000..9036122a6 --- /dev/null +++ b/spec/features/beta_testers_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 5773293cd..01aa85cdd 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -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')