add controller tests

This commit is contained in:
2026-01-23 12:20:31 +01:00
parent dea0ef508a
commit 35c29749fb
16 changed files with 515 additions and 51 deletions
@@ -0,0 +1,36 @@
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