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
+30
View File
@@ -0,0 +1,30 @@
require "test_helper"
class UsersControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "update" do
assert true
end
test "destroy" do
assert_difference -> { User.active.count }, -1 do
delete user_url(users(:david))
end
assert_redirected_to users_path
assert_nil User.active.find_by(id: users(:david).id)
end
test "non-admins cannot perform actions" do
sign_in_as :jz
put user_url(users(:david)), params: { user: { role: "admin" } }
assert_response :forbidden
delete user_url(users(:david))
assert_response :forbidden
end
end