summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-09-02 09:41:24 +0200
committerAzul <azul@leap.se>2013-09-03 08:32:19 +0200
commit1bcc76b4f50a181a1b3c137c79b627257187ac3c (patch)
tree9f0dcf015b68fc29722643e5066b99ee520d61ee
parent1210f91251b14c251b2d4a6de7665fa520b77864 (diff)
integration test for displaying internal server error during signup
-rw-r--r--test/functional/error_handling_test.rb2
-rw-r--r--users/test/integration/browser/account_test.rb25
2 files changed, 20 insertions, 7 deletions
diff --git a/test/functional/error_handling_test.rb b/test/functional/error_handling_test.rb
index 04ea722..47e44ce 100644
--- a/test/functional/error_handling_test.rb
+++ b/test/functional/error_handling_test.rb
@@ -10,6 +10,8 @@ class ErrorHandlingTest < ActionController::TestCase
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
diff --git a/users/test/integration/browser/account_test.rb b/users/test/integration/browser/account_test.rb
index b412980..f3a78ed 100644
--- a/users/test/integration/browser/account_test.rb
+++ b/users/test/integration/browser/account_test.rb
@@ -7,13 +7,7 @@ class AccountTest < BrowserIntegrationTest
end
test "normal account workflow" do
- username = "test_#{SecureRandom.urlsafe_base64}".downcase
- password = SecureRandom.base64
- visit '/users/new'
- fill_in 'Username', with: username
- fill_in 'Password', with: password
- fill_in 'Password confirmation', with: password
- click_on 'Sign Up'
+ username, password = submit_signup
assert page.has_content?("Welcome #{username}")
click_on 'Logout'
assert page.has_content?("Sign Up")
@@ -32,6 +26,23 @@ class AccountTest < BrowserIntegrationTest
assert page.has_no_content?("Welcome")
end
+ test "reports internal server errors" do
+ V1::UsersController.any_instance.stubs(:create).raises
+ submit_signup
+ assert page.has_content?("server failed")
+ end
+
+ def submit_signup
+ username = "test_#{SecureRandom.urlsafe_base64}".downcase
+ password = SecureRandom.base64
+ visit '/users/new'
+ fill_in 'Username', with: username
+ fill_in 'Password', with: password
+ fill_in 'Password confirmation', with: password
+ click_on 'Sign Up'
+ return username, password
+ end
+
def inject_malicious_js
page.execute_script <<-EOJS
var calc = new srp.Calculate();