dashboard controller
This commit is contained in:
18
test/controllers/admin/dashboard_controller_test.rb
Normal file
18
test/controllers/admin/dashboard_controller_test.rb
Normal file
@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
module Admin
|
||||
class DashboardControllerTest < ActionDispatch::IntegrationTest
|
||||
test "dashboard should require auth" do
|
||||
get admin_url
|
||||
assert_redirected_to admin_login_url
|
||||
end
|
||||
|
||||
test "should get dashboard" do
|
||||
post admin_auth_url, params: { auth:
|
||||
{ email: 'alan.admin@mailinator.com', password: 'password' } }
|
||||
get admin_url
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
@ -2,15 +2,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class AdminControllerTest < ActionDispatch::IntegrationTest
|
||||
test "dashboard should require auth" do
|
||||
get admin_url
|
||||
assert_redirected_to admin_login_url
|
||||
end
|
||||
|
||||
test "should get dashboard" do
|
||||
post admin_auth_url, params: { auth:
|
||||
{ email: 'alan.admin@mailinator.com', password: 'password' } }
|
||||
get admin_url
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
@ -13,11 +13,11 @@ class UserPolicyTest < PolicyAssertions::Test
|
||||
assert_equal User.count, scope.count
|
||||
end
|
||||
|
||||
test 'should not allow non_admin to scope' do
|
||||
test 'non admins can only scope themselves' do
|
||||
%i(manager reviewer recruiter).each do |role|
|
||||
assert_raise Pundit::NotAuthorizedError, "Failed to raise auth error for #{role}" do
|
||||
UserPolicy::Scope.new(users(role), User).resolve
|
||||
end
|
||||
scope = UserPolicy::Scope.new(users(role), User).resolve
|
||||
assert_equal 1, scope.count, "Scope did not have 1 result for #{role}"
|
||||
assert_equal users(role), scope.first, "Scope did not contain self for #{role}"
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user