Skip to content

Commit

Permalink
Merge b495797 into eee6c5b
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Sep 5, 2019
2 parents eee6c5b + b495797 commit 0335134
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .rubocop.yml
@@ -1,6 +1,8 @@
inherit_from: .rubocop_todo.yml

require: rubocop-rspec
require:
- rubocop-rspec
- rubocop-rails

AllCops:
TargetRubyVersion: 2.5
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -43,7 +43,8 @@ group :test, :development do
gem 'rack-console'
gem 'rails-controller-testing'
gem 'rspec-rails'
gem 'rubocop', '~> 0.65.0'
gem 'rubocop', '~> 0.74.0'
gem 'rubocop-rails'
gem 'rubocop-rspec', '~> 1.32.0'
gem 'simplecov'
gem 'webmock'
Expand Down
18 changes: 9 additions & 9 deletions Gemfile.lock
Expand Up @@ -266,9 +266,7 @@ GEM
parallel (1.17.0)
parser (2.6.4.0)
ast (~> 2.4.0)
powerpack (0.1.2)
progressbar (1.10.1)
psych (3.1.0)
public_suffix (4.0.1)
puma (3.12.1)
rack (2.0.7)
Expand Down Expand Up @@ -355,15 +353,16 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.2)
rubocop (0.65.0)
rubocop (0.74.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
psych (>= 3.1.0)
parser (>= 2.6)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-rails (2.3.2)
rack (>= 1.1)
rubocop (>= 0.72.0)
rubocop-rspec (1.32.0)
rubocop (>= 0.60.0)
ruby-cache (0.3.0)
Expand Down Expand Up @@ -423,7 +422,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.6)
unicode-display_width (1.4.1)
unicode-display_width (1.6.0)
uuidtools (2.1.5)
webmock (3.7.1)
addressable (>= 2.3.6)
Expand Down Expand Up @@ -463,7 +462,8 @@ DEPENDENCIES
rails-controller-testing
rest-client
rspec-rails
rubocop (~> 0.65.0)
rubocop (~> 0.74.0)
rubocop-rails
rubocop-rspec (~> 1.32.0)
ruby-cache (~> 0.3.0)
simplecov
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -22,7 +22,7 @@ class ApplicationController < ActionController::API
# Ensure a valid token is present, or renders "401: Not Authorized"
def check_auth_token
token = decoded_auth_token
return render json: { error: 'Not Authorized' }, status: 401 unless token
return render json: { error: 'Not Authorized' }, status: :unauthorized unless token

Honeybadger.context(invoked_by: token[:sub])
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/embargoes_controller.rb
Expand Up @@ -11,6 +11,6 @@ def update
@item.events.add_event('Embargo', params[:requesting_user], 'Embargo date modified')
head :no_content
rescue ArgumentError => e
render status: 422, plain: e.message
render status: :unprocessable_entity, plain: e.message
end
end
16 changes: 8 additions & 8 deletions app/controllers/objects_controller.rb
Expand Up @@ -4,15 +4,15 @@ class ObjectsController < ApplicationController
before_action :load_item, except: [:create]

rescue_from(Dor::ParameterError) do |e|
render status: 400, plain: e.message
render status: :bad_request, plain: e.message
end

rescue_from(Dor::DuplicateIdError) do |e|
render status: 409, plain: e.message, location: object_location(e.pid)
render status: :conflict, plain: e.message, location: object_location(e.pid)
end

rescue_from(DublinCoreService::CrosswalkError) do |e|
render status: 500, plain: e.message
render status: :internal_server_error, plain: e.message
end

# Register new objects in DOR
Expand All @@ -21,14 +21,14 @@ def create
begin
reg_response = RegistrationService.create_from_request(create_params)
rescue ArgumentError => e
return render status: 422, plain: e.message
return render status: :unprocessable_entity, plain: e.message
end
Rails.logger.info(reg_response)
pid = reg_response[:pid]

respond_to do |format|
format.all { render status: 201, location: object_location(pid), plain: Dor::RegistrationResponse.new(reg_response).to_txt }
format.json { render status: 201, location: object_location(pid), json: Dor::RegistrationResponse.new(reg_response) }
format.all { render status: :created, location: object_location(pid), plain: Dor::RegistrationResponse.new(reg_response).to_txt }
format.json { render status: :created, location: object_location(pid), json: Dor::RegistrationResponse.new(reg_response) }
end
end

Expand Down Expand Up @@ -62,7 +62,7 @@ def notify_goobi
response = Dor::Goobi.new(@item).register
proxy_rest_client_response(response)
rescue RestClient::Conflict => e
render status: 409, plain: e.http_body
render status: :conflict, plain: e.http_body
end

# You can post a release tag as JSON in the body to add a release tag to an item.
Expand All @@ -80,7 +80,7 @@ def release_tags
@item.save
head :created
else
render status: 400, plain: "A release attribute is required in the JSON, and its value must be either 'true' or 'false'. You sent '#{raw_params[:release]}'"
render status: :bad_request, plain: "A release attribute is required in the JSON, and its value must be either 'true' or 'false'. You sent '#{raw_params[:release]}'"
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sdr_controller.rb
Expand Up @@ -3,7 +3,7 @@
class SdrController < ApplicationController
def cm_inv_diff
unless %w(all shelve preserve publish).include?(params[:subset].to_s)
render status: 400, plain: "Invalid subset value: #{params[:subset]}"
render status: :bad_request, plain: "Invalid subset value: #{params[:subset]}"
return
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/workspaces_controller.rb
Expand Up @@ -3,7 +3,7 @@
# Handles API routes for managing the DOR workspace
class WorkspacesController < ApplicationController
rescue_from(DruidTools::SameContentExistsError, DruidTools::DifferentContentExistsError) do |e|
render status: 409, plain: e.message
render status: :conflict, plain: e.message
end

# POST /v1/objects/:druid/workspace
Expand Down
4 changes: 2 additions & 2 deletions spec/services/cleanup_service_spec.rb
Expand Up @@ -24,8 +24,8 @@
workitem_pathname.rmtree if workitem_pathname.exist?
export_pathname = Pathname(Settings.cleanup.local_export_home)
export_pathname.rmtree if export_pathname.exist?
bag_pathname = export_pathname.join(druid.split(':').last)
tarfile_pathname = export_pathname.join(bag_pathname + '.tar')
bag_pathname = export_pathname.join(druid.split(':').last)
tarfile_pathname = export_pathname.join(bag_pathname + '.tar')

workitem_pathname.join('content').mkpath
workitem_pathname.join('temp').mkpath
Expand Down
4 changes: 2 additions & 2 deletions spec/services/public_desc_metadata_service_spec.rb
Expand Up @@ -118,7 +118,7 @@
doc = Nokogiri::XML(xml)
expect(doc.encoding).to eq('UTF-8')
expect(doc.xpath('//comment()').size).to eq 0
collections = doc.search('//mods:relatedItem/mods:typeOfResource[@collection=\'yes\']')
collections = doc.search('//mods:relatedItem/mods:typeOfResource[@collection=\'yes\']')
collection_title = doc.search('//mods:relatedItem/mods:titleInfo/mods:title')
collection_uri = doc.search('//mods:relatedItem/mods:location/mods:url')
expect(collections.length).to eq 1
Expand Down Expand Up @@ -147,7 +147,7 @@

it 'handles mods as the default namespace' do
doc = Nokogiri::XML(xml)
collections = doc.search('//xmlns:relatedItem/xmlns:typeOfResource[@collection=\'yes\']')
collections = doc.search('//xmlns:relatedItem/xmlns:typeOfResource[@collection=\'yes\']')
collection_title = doc.search('//xmlns:relatedItem/xmlns:titleInfo/xmlns:title')
collection_uri = doc.search('//xmlns:relatedItem/xmlns:location/xmlns:url')
expect(collections.length).to eq 1
Expand Down

0 comments on commit 0335134

Please sign in to comment.