Files
sanasto-wiki/test/controllers/admin/dashboard_controller_test.rb

37 lines
1.1 KiB
Ruby

require "test_helper"
class Admin::DashboardControllerTest < ActionDispatch::IntegrationTest
test "should redirect to login when not authenticated" do
get admin_root_path
assert_redirected_to login_path
follow_redirect!
assert_select ".bg-red-50", /You must be logged in/
end
test "should redirect to root when logged in as non-admin" do
login_as(users(:contributor_user))
get admin_root_path
assert_redirected_to root_path
assert_equal "You must be an administrator to access this page.", flash[:alert]
end
test "should redirect to root when logged in as reviewer" do
login_as(users(:reviewer_user))
get admin_root_path
assert_redirected_to root_path
assert_equal "You must be an administrator to access this page.", flash[:alert]
end
test "should show dashboard when logged in as admin" do
login_as(users(:admin_user))
get admin_root_path
assert_response :success
end
test "should show admin dashboard path" do
login_as(users(:admin_user))
get admin_dashboard_path
assert_response :success
end
end