Skip to content

Commit

Permalink
Merge pull request #4050 from avalonmediasystem/bug_fixes
Browse files Browse the repository at this point in the history
Do not inline structure if query parameter is false
  • Loading branch information
cjcolvar authored Mar 16, 2020
2 parents e8cebdd + aba5a47 commit a512319
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/media_objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def show
end
end
format.json do
response_json = @media_object.as_json(include_structure: params[:include_structure])
response_json = @media_object.as_json(include_structure: params[:include_structure] == "true")
response_json.except!(:files, :visibility, :read_groups) unless current_ability.can? :edit, @media_object
render json: response_json.to_json
end
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/media_objects_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,11 @@
get 'show', params: { id: media_object.id, format:'json', include_structure: true }
expect(json['files'].first['structure']).to eq master_file.structuralMetadata.content
end

it "should not return structure inline if requested not to" do
get 'show', params: { id: media_object.id, format:'json', include_structure: false }
expect(json['files'].first['structure']).not_to eq master_file.structuralMetadata.content
end
end
end
end
Expand Down

0 comments on commit a512319

Please sign in to comment.