Skip to content

Commit

Permalink
fix: handle private hook implementations
Browse files Browse the repository at this point in the history
This fixes a regression introduced in #402.

Co-authored-by: Gonzalo Bulnes Guilpain <[email protected]>
  • Loading branch information
dmke and gonzalo-bulnes committed Jan 3, 2023
1 parent c5a3fd0 commit 6d5f7e2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Fixed

- Fix a regression introduced by #402, that caused hooks not to be invoked - @dmke

## [1.18.0] - 2022-12-27

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def authenticate_entity_from_token!(entity)

if token_correct?(record, entity, token_comparator)
perform_sign_in!(record, sign_in_handler)
after_successful_token_authentication if respond_to?(:after_successful_token_authentication)
after_successful_token_authentication if respond_to?(:after_successful_token_authentication, true)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,21 @@
expect(token_authentication_handler).to have_received(:after_successful_token_authentication).once
end
end

context 'when the handler implements a private :after_successful_token_authentication', protected: true do
before(:each) do
token_authentication_handler.singleton_class.send(:include, Module.new {
def after_successful_token_authentication; end
private :after_successful_token_authentication
})
allow(token_authentication_handler).to receive(:after_successful_token_authentication)
end

it 'calls the :after_successful_token_authentication hook' do
token_authentication_handler.send(:authenticate_entity_from_token!, double)
expect(token_authentication_handler).to have_received(:after_successful_token_authentication).once
end
end
end
end
end

0 comments on commit 6d5f7e2

Please sign in to comment.