Files
danbooru/test/functional/user_name_change_requests_controller_test.rb
evazion 3b63f94968 user name changes: remove unused reason, status fields.
Remove all infrastructure around approving or rejecting user name
changes. Name changes haven't been moderated for several years.

* Remove status, approver_id, change_reason, and rejection_reason fields.
* Remove approve and reject controller actions.
2019-09-25 21:43:01 -05:00

55 lines
1.5 KiB
Ruby

require 'test_helper'
class UserNameChangeRequestsControllerTest < ActionDispatch::IntegrationTest
context "The user name change requests controller" do
setup do
@user = create(:gold_user)
@admin = create(:admin_user)
end
context "new action" do
should "render" do
get_auth new_user_name_change_request_path, @user
assert_response :success
end
end
context "create action" do
should "work" do
post_auth user_name_change_requests_path, @user, params: { user_name_change_request: { desired_name: "zun" }}
assert_response :redirect
assert_equal("zun", @user.reload.name)
end
end
context "show action" do
setup do
@change_request = as(@user) { create(:user_name_change_request, user_id: @user.id) }
end
should "render" do
get_auth user_name_change_request_path(@change_request), @admin
assert_response :success
end
context "when the current user is not an admin and does not own the request" do
should "fail" do
@another_user = create(:user)
get_auth user_name_change_request_path(@change_request), @another_user
assert_response :forbidden
end
end
end
context "for actions restricted to admins" do
context "index action" do
should "render" do
get_auth user_name_change_requests_path, @admin
assert_response :success
end
end
end
end
end