tabletop-companion/test/controllers/users_controller_test.rb

41 lines
892 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
2024-04-21 14:01:10 +00:00
assert_redirected_to login_path
2024-04-14 19:01:32 +00:00
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