diff --git a/lib/pact_broker/api/resources/base_resource.rb b/lib/pact_broker/api/resources/base_resource.rb index 65e3c5635..135e7ecd8 100644 --- a/lib/pact_broker/api/resources/base_resource.rb +++ b/lib/pact_broker/api/resources/base_resource.rb @@ -96,12 +96,12 @@ def pact_params end def set_json_error_message message - response.headers['Content-Type'] = 'application/json;charset=utf-8' + response.headers['Content-Type'] = 'application/hal+json;charset=utf-8' response.body = {error: message}.to_json end def set_json_validation_error_messages errors - response.headers['Content-Type'] = 'application/json;charset=utf-8' + response.headers['Content-Type'] = 'application/hal+json;charset=utf-8' response.body = {errors: errors}.to_json end @@ -128,7 +128,7 @@ def invalid_json? rescue StandardError => e logger.error "Error parsing JSON #{e} - #{request_body}" set_json_error_message "Error parsing JSON - #{e.message}" - response.headers['Content-Type'] = 'application/json;charset=utf-8' + response.headers['Content-Type'] = 'application/hal+json;charset=utf-8' true end end diff --git a/lib/pact_broker/api/resources/pact_webhooks.rb b/lib/pact_broker/api/resources/pact_webhooks.rb index c861b27a4..d31ee272e 100644 --- a/lib/pact_broker/api/resources/pact_webhooks.rb +++ b/lib/pact_broker/api/resources/pact_webhooks.rb @@ -38,7 +38,7 @@ def validation_errors? webhook errors = webhook_service.errors(webhook) unless errors.empty? - response.headers['Content-Type'] = 'application/json;charset=utf-8' + response.headers['Content-Type'] = 'application/hal+json;charset=utf-8' response.body = { errors: errors.messages }.to_json end diff --git a/spec/features/create_webhook_spec.rb b/spec/features/create_webhook_spec.rb index 37325a8f1..0a06db136 100644 --- a/spec/features/create_webhook_spec.rb +++ b/spec/features/create_webhook_spec.rb @@ -24,7 +24,7 @@ it "returns a JSON content type" do subject - expect(last_response.headers['Content-Type']).to eq 'application/json;charset=utf-8' + expect(last_response.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8' end it "returns the validation errors" do diff --git a/spec/lib/pact_broker/api/resources/pact_spec.rb b/spec/lib/pact_broker/api/resources/pact_spec.rb index 3336494f2..87cc9fc34 100644 --- a/spec/lib/pact_broker/api/resources/pact_spec.rb +++ b/spec/lib/pact_broker/api/resources/pact_spec.rb @@ -76,7 +76,7 @@ module Resources end it "returns a JSON content type" do - expect(response.headers['Content-Type']).to eq "application/json;charset=utf-8" + expect(response.headers['Content-Type']).to eq "application/hal+json;charset=utf-8" end it "returns an error message" do diff --git a/spec/lib/pact_broker/api/resources/pact_webhooks_spec.rb b/spec/lib/pact_broker/api/resources/pact_webhooks_spec.rb index 68b58ade0..9c2953986 100644 --- a/spec/lib/pact_broker/api/resources/pact_webhooks_spec.rb +++ b/spec/lib/pact_broker/api/resources/pact_webhooks_spec.rb @@ -93,7 +93,7 @@ module Resources it "returns a JSON content type" do subject - expect(last_response.headers['Content-Type']).to eq 'application/json;charset=utf-8' + expect(last_response.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8' end it "returns an error message" do @@ -111,7 +111,7 @@ module Resources it "returns a JSON content type" do subject - expect(last_response.headers['Content-Type']).to eq 'application/json;charset=utf-8' + expect(last_response.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8' end it "returns an error message" do @@ -132,7 +132,7 @@ module Resources it "returns a JSON content type" do subject - expect(last_response.headers['Content-Type']).to eq 'application/json;charset=utf-8' + expect(last_response.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8' end it "returns the validation errors" do diff --git a/spec/support/shared_examples_for_responses.rb b/spec/support/shared_examples_for_responses.rb index b98912b98..6907a6ca6 100644 --- a/spec/support/shared_examples_for_responses.rb +++ b/spec/support/shared_examples_for_responses.rb @@ -24,14 +24,14 @@ RSpec::Matchers.define :be_a_json_response do match do | actual | - expect(actual.headers['Content-Type']).to eq 'application/json;charset=utf-8' + expect(actual.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8' end end RSpec::Matchers.define :be_a_json_error_response do | message | match do | actual | expect(actual.status).to be 400 - expect(actual.headers['Content-Type']).to eq 'application/json;charset=utf-8' + expect(actual.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8' expect(actual.body).to include message end end