Make /admin and /moderation only accesible to Admins & Moderators

This commit is contained in:
kikito
2015-08-07 19:15:08 +02:00
parent 9eae91c764
commit dac5b8d22a
7 changed files with 99 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
require 'rails_helper'
feature 'Admin' do
let(:user) { create(:user) }
scenario 'Access as regular user is not authorized' do
login_as(user)
visit moderation_root_path
expect(current_path).to eq(root_path)
expect(page).to have_content "not authorized"
end
scenario 'Access as a moderator is authorized' do
create(:moderator, user: user)
login_as(user)
visit moderation_root_path
expect(current_path).to eq(moderation_root_path)
expect(page).to_not have_content "not authorized"
end
scenario 'Access as an administrator is authorized' do
create(:administrator, user: user)
login_as(user)
visit moderation_root_path
expect(current_path).to eq(moderation_root_path)
expect(page).to_not have_content "not authorized"
end
end