diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d5b05c6ae..6e3f55b6d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -34,7 +34,7 @@ class ApplicationController < ActionController::Base end def authenticate_beta_tester! - unless beta_testers.include?(current_user.email) + unless signed_in? && beta_testers.include?(current_user.email) sign_out(current_user) redirect_to new_user_session_path, alert: t('application.alert.only_beta_testers') end diff --git a/spec/features/beta_testers_spec.rb b/spec/features/beta_testers_spec.rb index 20aef50e0..66492b219 100644 --- a/spec/features/beta_testers_spec.rb +++ b/spec/features/beta_testers_spec.rb @@ -34,4 +34,11 @@ feature 'Beta testers' do expect(page).to have_content "Sorry only Beta Testers are allowed access at the moment" 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 \ No newline at end of file