summaryrefslogtreecommitdiff
path: root/core/test/support
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-02-08 12:29:08 +0100
committerAzul <azul@leap.se>2014-02-10 14:26:30 +0100
commit758b9a3c30a73fd985943fb7a887f0373be3a833 (patch)
tree935bf639bb17ea034d7864205d087f6cd3497175 /core/test/support
parent67f17e65b9e9e8ad2991b9c4002dba5203baa77f (diff)
split up and expand account integration test
Diffstat (limited to 'core/test/support')
-rw-r--r--core/test/support/rack_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/core/test/support/rack_test.rb b/core/test/support/rack_test.rb
index 0476cf7..2d8e5c4 100644
--- a/core/test/support/rack_test.rb
+++ b/core/test/support/rack_test.rb
@@ -10,4 +10,28 @@ class RackTest < ActiveSupport::TestCase
OUTER_APP
end
+ def assert_access_denied
+ assert_json_response('error' => I18n.t(:not_authorized))
+ assert_response :unprocessable_entity
+ end
+
+ # inspired by rails 4
+ # -> actionpack/lib/action_dispatch/testing/assertions/response.rb
+ def assert_response(type, message = nil)
+ # RackTest does not know @response
+ response_code = last_response.status
+ message ||= "Expected response to be a <#{type}>, but was <#{response_code}>"
+
+ if Symbol === type
+ if [:success, :missing, :redirect, :error].include?(type)
+ assert last_response.send("#{type}?"), message
+ else
+ code = Rack::Utils::SYMBOL_TO_STATUS_CODE[type]
+ assert_equal code, response_code, message
+ end
+ else
+ assert_equal type, response_code, message
+ end
+ end
+
end