Skip to content

Commit e1ea9b2

Browse files
Merge branch 'fix-hook-regression'
Fix regression: ensure private hooks are invoked
2 parents c5a3fd0 + 6d5f7e2 commit e1ea9b2

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6+
## [Unreleased]
7+
8+
### Fixed
9+
10+
- Fix a regression introduced by #402, that caused hooks not to be invoked - @dmke
11+
612
## [1.18.0] - 2022-12-27
713

814
### Added

lib/simple_token_authentication/token_authentication_handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def authenticate_entity_from_token!(entity)
3232

3333
if token_correct?(record, entity, token_comparator)
3434
perform_sign_in!(record, sign_in_handler)
35-
after_successful_token_authentication if respond_to?(:after_successful_token_authentication)
35+
after_successful_token_authentication if respond_to?(:after_successful_token_authentication, true)
3636
end
3737
end
3838

spec/lib/simple_token_authentication/token_authentication_handler_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,21 @@
736736
expect(token_authentication_handler).to have_received(:after_successful_token_authentication).once
737737
end
738738
end
739+
740+
context 'when the handler implements a private :after_successful_token_authentication', protected: true do
741+
before(:each) do
742+
token_authentication_handler.singleton_class.send(:include, Module.new {
743+
def after_successful_token_authentication; end
744+
private :after_successful_token_authentication
745+
})
746+
allow(token_authentication_handler).to receive(:after_successful_token_authentication)
747+
end
748+
749+
it 'calls the :after_successful_token_authentication hook' do
750+
token_authentication_handler.send(:authenticate_entity_from_token!, double)
751+
expect(token_authentication_handler).to have_received(:after_successful_token_authentication).once
752+
end
753+
end
739754
end
740755
end
741756
end

0 commit comments

Comments
 (0)