diff options
author | jessib <jessib@riseup.net> | 2013-09-03 10:38:39 -0700 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2013-09-03 10:38:39 -0700 |
commit | f97777ed0252abe94f8d94cb4565fb5a6c35ab23 (patch) | |
tree | c943e772cf403387822364bbcbe23f59bdb17504 /test/functional/error_handling_test.rb | |
parent | a3e7cf7b667ec2080d8930b3c2659978a4c95a9b (diff) | |
parent | 1bcc76b4f50a181a1b3c137c79b627257187ac3c (diff) |
Merge pull request #76 from azul/feature/3600-visual-feedback-on-failed-signup
Ensure json requests get json error response on failure
Diffstat (limited to 'test/functional/error_handling_test.rb')
-rw-r--r-- | test/functional/error_handling_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/functional/error_handling_test.rb b/test/functional/error_handling_test.rb new file mode 100644 index 0000000..47e44ce --- /dev/null +++ b/test/functional/error_handling_test.rb @@ -0,0 +1,22 @@ +require 'test_helper' + +class ErrorHandlingTest < ActionController::TestCase + tests HomeController + + def setup + HomeController.any_instance.stubs(:index).raises + end + + def test_json_error + get :index, format: :json + assert_equal 'application/json', @response.content_type + assert json = JSON.parse(@response.body) + assert_equal ['error'], json.keys + end + + def test_html_error_reraises + assert_raises RuntimeError do + get :index + end + end +end |