Skip to content

Commit

Permalink
add badArgument error to GetRecord next-l/enju_leaf#765
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Sep 26, 2015
1 parent d8e2434 commit e88c667
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions app/controllers/oai_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ def get_record
@manifestation = Manifestation.find_by_oai_identifier(params[:identifier])
rescue ActiveRecord::RecordNotFound
@oai[:errors] << "idDoesNotExist"
render template: 'oai/provider', content_type: 'text/xml'
end
render template: 'oai/get_record', content_type: 'text/xml'
return
else
@oai[:errors] << "idDoesNotExist"
end

if @oai[:errors].empty?
render template: 'oai/get_record', content_type: 'text/xml'
else
render template: 'oai/provider', content_type: 'text/xml'
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/enju_oai/oai_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def check_oai_params(params)
oai[:errors] << "badArgument"
end
when 'GetRecord'
unless valid_metadata_format?(params[:metadataPrefix])
oai[:errors] << "badArgument"
end
if params[:identifier].blank?
oai[:errors] << "badArgument"
end
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/oai_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def valid_attributes
response.should render_template('oai/provider')
end

it "assigns all manifestations as @manifestations in oai format with GetRecord with identifier" do
it "should not assign all manifestations as @manifestations in oai format with GetRecord with identifier without metadataPrefix" do
get :provider, format: 'xml', :verb => 'GetRecord', :identifier => 'oai:localhost:manifestations-1'
assigns(:manifestations).should be_nil
assigns(:manifestation).should_not be_nil
response.should render_template('oai/get_record')
response.should render_template('oai/provider')
end
it "assigns all manifestations as @manifestations in oai format with GetRecord with identifier for junii2 metadata" do
get :provider, format: 'xml', :verb => 'GetRecord', :identifier => 'oai:localhost:manifestations-1', :metadataPrefix => 'junii2'
Expand Down

0 comments on commit e88c667

Please sign in to comment.