diff options
author | elijah <elijah@riseup.net> | 2014-12-04 15:16:25 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-12-04 15:16:25 -0800 |
commit | 7ca1a6feb2f881f2a99b624c266f0779d2402ff9 (patch) | |
tree | 43ee2d96ba1281fae3e098dffe55aa1bc0a0e409 /tests/helpers/bonafide_helper.rb | |
parent | 60bd76583d46fe1c9f39804c7fd892fa9c1745d0 (diff) |
tests - better errors, ensure tmp users are deleted, remove bad 'pass()' call that made tmp_user tests always succeed.
Diffstat (limited to 'tests/helpers/bonafide_helper.rb')
-rw-r--r-- | tests/helpers/bonafide_helper.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/helpers/bonafide_helper.rb b/tests/helpers/bonafide_helper.rb index c84ea142..d96b3977 100644 --- a/tests/helpers/bonafide_helper.rb +++ b/tests/helpers/bonafide_helper.rb @@ -8,10 +8,13 @@ class LeapTest user = assert_create_user assert_authenticate_user(user) yield user if block_given? - rescue - # ^^ ensure here would eat any failed assertions assert_delete_user(user) - raise + rescue StandardError, MiniTest::Assertion => exc + begin + assert_delete_user(user) + rescue + end + raise exc end def api_url(path) @@ -67,19 +70,16 @@ class LeapTest # attempts to destroy a user account via the API. # def assert_delete_user(user) - if user && user.ok && user.id && user.session_token + if user && user.ok && user.id && user.session_token && !user.deleted url = api_url("/1/users/#{user.id}.json") options = {:headers => { "Authorization" => "Token token=\"#{user.session_token}\"" }} + user.deleted = true delete(url, {}, options) do |body, response, error| - if response.code.to_i != 200 - skip "It appears the web api is too old to support deleting users" - else - assert(response = JSON.parse(body), 'response should be JSON') - assert(response["success"], 'delete should be a success') - pass - end + assert response.code.to_i == 200, "Unable to delete user: HTTP response from API should have code 200, was #{response.code} #{error} #{body}" + assert(response = JSON.parse(body), 'Delete response should be JSON') + assert(response["success"], 'Deleting user should be a success') end end end |