Skip to content

Commit c9d48c5

Browse files
committed
Call sorcery config block where it is defined
[Sorcery#227] Before this commit sorcery config block was saved into a variable and called after including `Sorcery::Controller` into `ActionController::Base` (in the included block). In Sorcery#209 the initialization code was changed to include `Sorcery::Controller` into `ActionController::Base` after loading action controller (in the onload block) to fix deprecation warning related to autoloading. After this change calling the user model in the rails development console started to fail with "To use reset_password submodule, you must define a mailer" error (Sorcery#227), because sorcery config block was not called (calling the user model doesn't load action controller) and `::Sorcery::Controller::Config.user_config` was nil Because of this issue changes in Sorcery#209 have been reverted (Sorcery#234) There is no need to delay calling sorcery config block until `Sorcery::Controller` is included into `ActionController::Base` This commit changes the code to call sorcery config where it is defined. It will allow to apply changes in Sorcery#209 to fix deprecation warning from autoloading
1 parent a02c124 commit c9d48c5

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

lib/sorcery/controller.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ def self.included(klass)
1414
# rubocop:enable Lint/HandleExceptions
1515
end
1616
end
17-
Config.update!
18-
Config.configure!
1917
end
2018

2119
module InstanceMethods

lib/sorcery/controller/config.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ def user_config(&blk)
5454
end
5555

5656
def configure(&blk)
57-
@configure_blk = blk
58-
end
59-
60-
def configure!
61-
@configure_blk.call(self) if @configure_blk
57+
update!
58+
blk.call(self) if blk
6259
end
6360
end
6461

spec/controllers/controller_activity_logging_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
login_user(user)
4646
now = Time.now.in_time_zone
4747
Timecop.freeze(now)
48+
49+
sorcery_controller_property_set(:register_logout_time, true)
4850
expect(user).to receive(:set_last_logout_at).with(be_within(0.1).of(now))
4951

5052
logout_user

0 commit comments

Comments
 (0)