1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00
Maybe/test/controllers/registrations_controller_test.rb

55 lines
1.6 KiB
Ruby
Raw Normal View History

2024-02-02 17:49:28 -06:00
require "test_helper"
class RegistrationsControllerTest < ActionDispatch::IntegrationTest
test "new" do
get new_registration_url
assert_response :success
end
test "create redirects to correct URL" do
2024-02-02 17:49:28 -06:00
post registration_url, params: { user: {
email: "john@example.com",
password: "password",
password_confirmation: "password" } }
assert_redirected_to root_url
end
test "create seeds default transaction categories" do
assert_difference "Category.count", Category::DEFAULT_CATEGORIES.size do
post registration_url, params: { user: {
email: "john@example.com",
password: "password",
password_confirmation: "password" } }
end
end
2024-02-02 17:49:28 -06:00
test "create when hosted requires an invite code" do
with_env_overrides REQUIRE_INVITE_CODE: "true" do
2024-02-02 19:48:45 -06:00
assert_no_difference "User.count" do
post registration_url, params: { user: {
email: "john@example.com",
password: "password",
password_confirmation: "password" } }
assert_redirected_to new_registration_url
2024-02-02 17:49:28 -06:00
2024-02-02 19:48:45 -06:00
post registration_url, params: { user: {
email: "john@example.com",
password: "password",
password_confirmation: "password",
invite_code: "foo" } }
assert_redirected_to new_registration_url
end
2024-02-02 17:49:28 -06:00
2024-02-02 19:48:45 -06:00
assert_difference "User.count", +1 do
post registration_url, params: { user: {
email: "john@example.com",
password: "password",
password_confirmation: "password",
invite_code: InviteCode.generate! } }
assert_redirected_to root_url
end
2024-02-02 17:49:28 -06:00
end
2024-02-02 19:48:45 -06:00
end
2024-02-02 17:49:28 -06:00
end