Skip to content

Commit

Permalink
Add some debug info to the assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
bf4 committed Jan 12, 2021
1 parent 4a86c4f commit ef72900
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/bug_1305_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ def test_get_individual
individual = Individual.create(name: 'test')
ContactMedium.create(party: individual, name: 'test contact medium')
get "/individuals/#{individual.id}"
assert last_response.ok?
assert_last_response_status 200
end

def test_get_party_via_contact_medium
individual = Individual.create(name: 'test')
contact_medium = ContactMedium.create(party: individual, name: 'test contact medium')
get "/contact_media/#{contact_medium.id}/party"
# pp [:last_response, last_response]
# ["{\"errors\":[{\"title\":\"Internal Server Error\",\"detail\":\"Internal Server Error\",\"code\":\"500\",\"status\":\"500\",\"meta\":{\"exception\":\"Can't join 'ContactMedium' to association named 'organization'; perhaps you misspelled it?\"
assert last_response.ok?, "Expect an individual to have been found via contact medium resource's relationship 'party'"
assert_last_response_status 200, "Expect an individual to have been found via contact medium resource's relationship 'party'"
end

private

def assert_last_response_status(status, failure_reason=nil)
if last_response.status != status
json_response = JSON.parse(last_response.body)
pp json_response
end
assert_equal status, last_response.status, failure_reason
end

def app
Rails.application
end
Expand Down

0 comments on commit ef72900

Please sign in to comment.