Skip to content

Commit

Permalink
Merge pull request #5919 from avalonmediasystem/sup_api_response
Browse files Browse the repository at this point in the history
Fail SupplementalFile Binary update if no Accept header
  • Loading branch information
masaball authored Jul 10, 2024
2 parents b37b981 + aaf3d4f commit da00ee6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/supplemental_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def update
raise Avalon::BadRequest, "Missing required Content-type headers" unless request.headers["Content-Type"] == 'application/json'
elsif request.headers['Avalon-Api-Key'].present?
raise Avalon::BadRequest, "Incorrect request format. Use JSON if updating metadata." unless attachment
raise Avalon::BadRequest, "Missing required Accept headers" unless request.headers["Accept"] == 'application/json'
end
raise Avalon::BadRequest, "Missing required parameters" unless validate_params

Expand Down
8 changes: 8 additions & 0 deletions spec/support/supplemental_files_controller_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,14 @@
expect(response).to have_http_status(:ok)
expect(response.body).to eq({ "id": supplemental_file.id }.to_json)
end

context "without Accept header" do
it "returns a 400" do
request.headers['Avalon-Api-Key'] = 'secret_token'
put :update, params: { class_id => object.id, id: supplemental_file.id, file: file_update, format: :html }, session: valid_session
expect(response).to have_http_status(400)
end
end
end

context "API without file" do
Expand Down

0 comments on commit da00ee6

Please sign in to comment.