Skip to content

Commit

Permalink
cleanup the memoized @engine_configuration so we can mock the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
tejanium committed Jan 11, 2024
1 parent 1e4f46b commit 065c4dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 0 additions & 4 deletions spec/apps/dummy/config/initializers/scimitar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ def scim_schemas_url(options)
def scim_resource_type_url(options)
super(test: 1, **options)
end

def valid_token
'A'
end
end

})
Expand Down
6 changes: 5 additions & 1 deletion spec/controllers/scimitar/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ def index
def index
render json: { 'message' => 'cool, cool!' }, format: :scim
end

def valid_token
'B'
end
end

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

get :index, params: { format: :scim }
expect(response).to be_ok
Expand Down
7 changes: 7 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
config.use_transactional_fixtures = true

Kernel.srand config.seed

config.around :each do | example |
original_engine_configuration = Scimitar.instance_variable_get('@engine_configuration')
example.run()
ensure
Scimitar.instance_variable_set('@engine_configuration', original_engine_configuration)
end
end

# ============================================================================
Expand Down

0 comments on commit 065c4dd

Please sign in to comment.