Skip to content

Commit

Permalink
fix: set correct content type for verification result resources
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed May 15, 2018
1 parent 0f9d0b0 commit c177fdd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/pact_broker/api/resources/verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/pact_broker/api/resources/verifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/features/publish_verification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c177fdd

Please sign in to comment.