1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-23 07:09:39 +02:00

Pull out in_hosted_app helper

This commit is contained in:
Jose Farias 2024-02-02 19:48:45 -06:00
parent 3852b79121
commit 78c84c5028
No known key found for this signature in database
GPG key ID: 877CF7E5FFD0FB3F

View file

@ -16,31 +16,38 @@ class RegistrationsControllerTest < ActionDispatch::IntegrationTest
end end
test "create when hosted requires an invite code" do test "create when hosted requires an invite code" do
in_hosted_app do
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
post registration_url, params: { user: {
email: "john@example.com",
password: "password",
password_confirmation: "password",
invite_code: "foo" } }
assert_redirected_to new_registration_url
end
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
end
end
private
def in_hosted_app
ENV["HOSTED"] = "true" ENV["HOSTED"] = "true"
yield
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
post registration_url, params: { user: {
email: "john@example.com",
password: "password",
password_confirmation: "password",
invite_code: "foo" } }
assert_redirected_to new_registration_url
end
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
ensure ensure
ENV["HOSTED"] = nil ENV["HOSTED"] = nil
end end