tabletop-companion/test/controllers/users_controller_test.rb

43 lines
923 B
Ruby

# frozen_string_literal: true
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 login_path
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