Join the two users controllers but split out role setting

This commit is contained in:
David Heinemeier Hansson
2025-04-12 20:30:47 +02:00
parent c463f342bf
commit a106b1b6a7
8 changed files with 51 additions and 33 deletions
@@ -0,0 +1,22 @@
require "test_helper"
class Users::RolesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "update" do
assert_not users(:david).admin?
put user_role_url(users(:david)), params: { user: { role: "admin" } }
assert_redirected_to users_path
assert users(:david).reload.admin?
end
test "can't promote to special roles" do
assert_no_changes -> { users(:david).reload.role } do
put user_role_url(users(:david)), params: { user: { role: "system" } }
end
end
end