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:
parent
3852b79121
commit
78c84c5028
1 changed files with 31 additions and 24 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue