From 98646d466c87fae5500a830f19edfe173ff04979 Mon Sep 17 00:00:00 2001 From: Andrew Hodgkinson Date: Fri, 12 Jan 2024 09:52:23 +1300 Subject: [PATCH] (Direcft to 'main') Small coding style tweak --- .../scimitar/application_controller_spec.rb | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/spec/controllers/scimitar/application_controller_spec.rb b/spec/controllers/scimitar/application_controller_spec.rb index 317996d..d1665cf 100644 --- a/spec/controllers/scimitar/application_controller_spec.rb +++ b/spec/controllers/scimitar/application_controller_spec.rb @@ -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 @@ -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'