Skip to content

Commit

Permalink
Merge pull request #54 from sul-dlss/rails5-compat
Browse files Browse the repository at this point in the history
 Use Rails 5-compatible 'head' instead of 'render nothing'
  • Loading branch information
mejackreed committed Mar 8, 2018
2 parents da05314 + c22020e commit 7e6303e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ notifications:
email: false

rvm:
- 2.4.3
- 2.3.1
- 2.2.5

env:
global:
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/base_indexer/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def update
end

@status = report_success
render nothing: true, status: 200
head :ok
Rails.logger.debug "Completing indexing of collection #{druid}"

rescue Exception => e
@status = report_failure request.method_symbol, params, e
Rails.logger.error @status
render nothing: true, status: 500
head :internal_server_error
end
end
end
8 changes: 4 additions & 4 deletions app/controllers/base_indexer/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ def update

indexer = BaseIndexer.indexer_class.constantize.new
indexer.index druid, { subtarget_params => true }
render nothing: true, status: 200
head :ok
Rails.logger.debug "Completing indexing #{druid}"
rescue StandardError => e
Rails.logger.error report_failure request.method_symbol, params, e
render nothing: true, status: 500
head :internal_server_error
end

def destroy
Expand All @@ -25,11 +25,11 @@ def destroy
# Only delete from specified subtarget
indexer.index druid, { subtarget_params => false }
end
render nothing: true, status: 200
head :ok
Rails.logger.debug "Completing deleting #{druid}"
rescue StandardError => e
Rails.logger.error report_failure request.method_symbol, params, e
render nothing: true, status: 500
head :internal_server_error
end

private
Expand Down
2 changes: 1 addition & 1 deletion base_indexer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency 'rails', '>= 4', '< 6'
s.add_dependency 'rails', '~> 5'
s.add_dependency 'discovery-indexer', '>= 2', '< 4'
s.add_dependency 'retries'
s.add_dependency 'dor-fetcher'
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/base_indexer/items_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
describe 'PATCH/PUT update' do
it 'creates an indexing job' do
expect(my_instance).to receive(:index).with('bb1111cc2222', 'SEARCHWORKS' => true)
patch :update, druid: 'druid:bb1111cc2222', subtarget: 'SEARCHWORKS', use_route: :base_indexer
patch :update, params: { druid: 'druid:bb1111cc2222', subtarget: 'SEARCHWORKS', use_route: :base_indexer }
expect(response.status).to eq 200
end
it 'when something bad happens return a 500' do
expect(my_instance).to receive(:index).with('bb1111cc2222', 'SEARCHWORKS' => true).and_raise(StandardError)
patch :update, druid: 'druid:bb1111cc2222', subtarget: 'SEARCHWORKS', use_route: :base_indexer
patch :update, params: { druid: 'druid:bb1111cc2222', subtarget: 'SEARCHWORKS', use_route: :base_indexer }
expect(response.status).to eq 500
end
end
describe 'DELETE destroy' do
context 'with a subtarget' do
it 'sends an "#index" with a false to the IndexerEngine' do
expect(my_instance).to receive(:index).with('bb1111cc2222', 'SEARCHWORKS' => false)
delete :destroy, druid: 'druid:bb1111cc2222', subtarget: 'SEARCHWORKS', use_route: :base_indexer
delete :destroy, params: { druid: 'druid:bb1111cc2222', subtarget: 'SEARCHWORKS', use_route: :base_indexer }
expect(response.status).to eq 200
end
end
context 'without a subtarget' do
it 'sends a "#delete" to the IndexerEngine' do
expect(my_instance).to receive(:delete).with('bb1111cc2222')
delete :destroy, druid: 'druid:bb1111cc2222', use_route: :base_indexer
delete :destroy, params: { druid: 'druid:bb1111cc2222', use_route: :base_indexer }
expect(response.status).to eq 200
end
end
Expand Down

0 comments on commit 7e6303e

Please sign in to comment.