Skip to content

Commit

Permalink
Disable autosave of session.authenticatable (cont.) (#219)
Browse files Browse the repository at this point in the history
* Disable autosave of session.authenticatable

This prevents the authenticable model from being auto-created when
`config.paranoid = true`.

Fixes #217.

* Add assertion

---------

Co-authored-by: nick evans <[email protected]>
  • Loading branch information
mikker and nevans committed Apr 25, 2024
1 parent 5f398d5 commit 053f233
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/passwordless/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class Session < ApplicationRecord
belongs_to(
:authenticatable,
polymorphic: true,
inverse_of: :passwordless_sessions
inverse_of: :passwordless_sessions,
autosave: false
)

validates(
Expand Down
1 change: 1 addition & 0 deletions test/controllers/passwordless/sessions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class << User
assert_equal 302, status

assert_equal 0, ActionMailer::Base.deliveries.size
assert_nil Session.last.authenticatable

follow_redirect!
assert_equal "/users/sign_in/#{Session.last!.identifier}", path
Expand Down

0 comments on commit 053f233

Please sign in to comment.