Closed mikker closed 9 months ago
using gem 'passwordless', github: 'mikker/passwordless', branch: 'fix-routes'
,
passwordless_for :users, at: '/', as: :auth
gives me the following routes:
=> looks good
However the tests do not pass.
When callingpasswordless_sign_in(User.first)
I get the following errors:
withpasswordless_for :users, at: '/', as: :auth
with passwordless_for :users, at: '/'
Hmm, that looks weird? Do you use the bundled mailer? It shouldn't use send
in this branch: https://github.com/mikker/passwordless/blob/fix-routes/app/mailers/passwordless/mailer.rb#L15-L24
Did you get a chance to look more into this, @yshmarov
I will try to make some time to test this later this week.
Hmm, that looks weird? Do you use the bundled mailer? It shouldn't use
send
in this branch: https://github.com/mikker/passwordless/blob/fix-routes/app/mailers/passwordless/mailer.rb#L15-L24
It is failing on this line: https://github.com/mikker/passwordless/blob/master/lib/passwordless/test_helpers.rb#L11
with this change it works for me:
def passwordless_sign_in(resource)
session = Passwordless::Session.create!(authenticatable: resource)
# magic_link = Passwordless::Engine.routes.url_helpers.send(
# :"confirm_#{session.authenticatable_type.tableize}_sign_in_url",
# session,
# session.token
# )
magic_link = url_for(
{
controller: "passwordless/sessions",
action: "confirm",
id: session.id,
token: session.token,
authenticatable: session.authenticatable_type.singularize.downcase,
resource: session.authenticatable_type.tableize
}
)
Of course, I didn't realise it was the test helpers. Fixed now, thanks!
Fixes #168
@yshmarov, @jpatters thank you for your reports. Could you try and see whether this fixes your problems? Thanks!