fixes exception when not logged in

This commit is contained in:
rgarcia
2015-09-06 11:26:15 +02:00
parent c28c39e052
commit afea21c2bc
2 changed files with 8 additions and 1 deletions

View File

@@ -34,7 +34,7 @@ class ApplicationController < ActionController::Base
end end
def authenticate_beta_tester! def authenticate_beta_tester!
unless beta_testers.include?(current_user.email) unless signed_in? && beta_testers.include?(current_user.email)
sign_out(current_user) sign_out(current_user)
redirect_to new_user_session_path, alert: t('application.alert.only_beta_testers') redirect_to new_user_session_path, alert: t('application.alert.only_beta_testers')
end end

View File

@@ -34,4 +34,11 @@ feature 'Beta testers' do
expect(page).to have_content "Sorry only Beta Testers are allowed access at the moment" expect(page).to have_content "Sorry only Beta Testers are allowed access at the moment"
end end
scenario "Trying to access site without being logged in" do
visit debates_path
expect(page).to have_content "Sorry only Beta Testers are allowed access at the moment"
expect(current_path).to eq(new_user_session_path)
end
end end