tabletop-companion/test/controllers/users_controller_test.rb

41 lines
887 B
Ruby
Raw Normal View History

2024-04-14 19:01:32 +00:00
require "test_helper"
class UsersControllerTest < ActionDispatch::IntegrationTest
test "should get new" do
get new_user_url
assert_response :success
end
test "should create user" do
assert_changes("User.count", +1) do
post(users_url, params: { user: user_params })
end
assert_redirected_to :root
end
test "should email user for confirmation" do
assert_emails(+1) do
post(users_url, params: { user: user_params })
end
end
test "should alert to invalid user" do
assert_no_changes("User.count") do
post(users_url, params: { user: { username: "new_user" } })
end
assert_response :unprocessable_entity
end
private
def user_params
{
username: "new_user",
password: "password",
email: "new_user@ex.com",
first_name: "new",
last_name: "user",
}
end
end