Skip to content

Commit

Permalink
Add only_path param to system test helpers (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
yenshirak authored Jan 24, 2024
1 parent 0428330 commit 3b12614
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/passwordless/test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,22 @@ def passwordless_sign_in(resource)
end

module SystemTestCase
def passwordless_sign_out(cls = nil)
def passwordless_sign_out(cls = nil, only_path: false)
cls ||= "User".constantize
resource = cls.model_name.to_s.tableize

visit(Passwordless.context.url_for(resource, action: "destroy"))
visit(Passwordless.context.url_for(resource, action: "destroy", only_path: only_path))
end

def passwordless_sign_in(resource)
def passwordless_sign_in(resource, only_path: false)
session = Passwordless::Session.create!(authenticatable: resource)

magic_link = Passwordless.context.url_for(
session,
action: "confirm",
id: session.to_param,
token: session.token
token: session.token,
only_path: only_path
)

visit(magic_link)
Expand Down

0 comments on commit 3b12614

Please sign in to comment.