From c177fdd41272292bddcf54b9e524069b921323d4 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Tue, 15 May 2018 17:41:30 +1000 Subject: [PATCH] fix: set correct content type for verification result resources --- lib/pact_broker/api/resources/verification.rb | 2 +- lib/pact_broker/api/resources/verifications.rb | 4 ++++ spec/features/publish_verification_spec.rb | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/pact_broker/api/resources/verification.rb b/lib/pact_broker/api/resources/verification.rb index 6af95d6ae..2feecdf7a 100644 --- a/lib/pact_broker/api/resources/verification.rb +++ b/lib/pact_broker/api/resources/verification.rb @@ -11,7 +11,7 @@ module Resources class Verification < BaseResource def content_types_provided - [["application/json", :to_json]] + [["application/hal+json", :to_json], ["application/json", :to_json]] end def allowed_methods diff --git a/lib/pact_broker/api/resources/verifications.rb b/lib/pact_broker/api/resources/verifications.rb index a90825fac..e9a413861 100644 --- a/lib/pact_broker/api/resources/verifications.rb +++ b/lib/pact_broker/api/resources/verifications.rb @@ -14,6 +14,10 @@ def content_types_accepted [["application/json", :from_json]] end + def content_types_provided + [["application/hal+json", :to_json]] + end + def allowed_methods ["POST"] end diff --git a/spec/features/publish_verification_spec.rb b/spec/features/publish_verification_spec.rb index 67a4277d5..45b761871 100644 --- a/spec/features/publish_verification_spec.rb +++ b/spec/features/publish_verification_spec.rb @@ -8,7 +8,7 @@ let(:parsed_response_body) { JSON.parse(subject.body) } let(:pact) { td.pact } - subject { post path, verification_content, {'CONTENT_TYPE' => 'application/json' }; last_response } + subject { post path, verification_content, {'CONTENT_TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/hal+json' }; last_response } before do td.create_provider("Provider") @@ -40,7 +40,7 @@ it "returns a link to itself that can be followed" do get_verification_link = parsed_response_body['_links']['self']['href'] - get get_verification_link + get get_verification_link, nil, { 'HTTP_ACCEPT' => 'application/hal+json' } expect(last_response.status).to be 200 expect(JSON.parse(subject.body)).to include JSON.parse(verification_content) end