Skip to content

Commit

Permalink
(Direcft to 'main') Small coding style tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
pond committed Jan 11, 2024
1 parent 8b3bd8d commit 98646d4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions spec/controllers/scimitar/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,9 @@ def index
end

context 'authenticator evaluated within controller context' do
before do
Scimitar.engine_configuration = Scimitar::EngineConfiguration.new(
token_authenticator: Proc.new do | token, options |
token == valid_token
end
)
end

# Define a controller with a custom instance method 'valid_token'.
#
controller do
def index
render json: { 'message' => 'cool, cool!' }, format: :scim
Expand All @@ -126,6 +121,17 @@ def valid_token
end
end

# Call the above controller method from the token authenticator Proc,
# proving that it was executed in the controller's context.
#
before do
Scimitar.engine_configuration = Scimitar::EngineConfiguration.new(
token_authenticator: Proc.new do | token, options |
token == self.valid_token()
end
)
end

it 'renders success when valid creds are given' do
request.env['HTTP_AUTHORIZATION'] = 'Bearer B'

Expand Down

0 comments on commit 98646d4

Please sign in to comment.