Skip to content

Commit ef72900

Browse files
committed
Add some debug info to the assertions
1 parent 4a86c4f commit ef72900

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

test/bug_1305_test.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,26 @@ def test_get_individual
2424
individual = Individual.create(name: 'test')
2525
ContactMedium.create(party: individual, name: 'test contact medium')
2626
get "/individuals/#{individual.id}"
27-
assert last_response.ok?
27+
assert_last_response_status 200
2828
end
2929

3030
def test_get_party_via_contact_medium
3131
individual = Individual.create(name: 'test')
3232
contact_medium = ContactMedium.create(party: individual, name: 'test contact medium')
3333
get "/contact_media/#{contact_medium.id}/party"
34-
# pp [:last_response, last_response]
35-
# ["{\"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?\"
36-
assert last_response.ok?, "Expect an individual to have been found via contact medium resource's relationship 'party'"
34+
assert_last_response_status 200, "Expect an individual to have been found via contact medium resource's relationship 'party'"
3735
end
3836

3937
private
4038

39+
def assert_last_response_status(status, failure_reason=nil)
40+
if last_response.status != status
41+
json_response = JSON.parse(last_response.body)
42+
pp json_response
43+
end
44+
assert_equal status, last_response.status, failure_reason
45+
end
46+
4147
def app
4248
Rails.application
4349
end

0 commit comments

Comments
 (0)