From b1b523f08a9ce7ea5fe0d50dc8b86995e00b48d6 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 24 Mar 2017 12:08:50 +0100 Subject: upgrade: simple_form to bootstrap 3 * reran the simple form initializer. * wrapped submit buttons are now broken and need a fix. * disabled confirmation validation in client side validations as the error message always is attached to the wrong field. --- test/integration/browser/account_livecycle_test.rb | 2 +- .../browser/password_validation_test.rb | 33 ++++++++++++---------- test/support/browser_integration_test.rb | 2 +- 3 files changed, 20 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/integration/browser/account_livecycle_test.rb b/test/integration/browser/account_livecycle_test.rb index 85dbf13..835dfdc 100644 --- a/test/integration/browser/account_livecycle_test.rb +++ b/test/integration/browser/account_livecycle_test.rb @@ -24,7 +24,7 @@ class AccountLivecycleTest < BrowserIntegrationTest visit '/signup' fill_in 'Username', with: username - fill_in 'Password', with: password + fill_in 'Password', with: password, match: :prefer_exact fill_in 'Password confirmation', with: password click_on 'Sign Up' diff --git a/test/integration/browser/password_validation_test.rb b/test/integration/browser/password_validation_test.rb index 51fcc5d..c5f0676 100644 --- a/test/integration/browser/password_validation_test.rb +++ b/test/integration/browser/password_validation_test.rb @@ -3,29 +3,32 @@ require 'test_helper' class PasswordValidationTest < BrowserIntegrationTest test "password confirmation is validated" do - username ||= "test_#{SecureRandom.urlsafe_base64}".downcase - password ||= SecureRandom.base64 - visit '/signup' - fill_in 'Username', with: username - fill_in 'Password', with: password - fill_in 'Password confirmation', with: password + "-typo" - click_on 'Sign Up' + password = SecureRandom.base64 + submit_signup_form password: password, confirmation: password + 'a' assert page.has_content? "does not match." assert_equal '/signup', current_path - assert page.has_selector? ".error #srp_password_confirmation" + assert_error_for 'srp_password_confirmation' end test "password needs to be at least 8 chars long" do + submit_signup_form password: SecureRandom.base64[0,7] + assert page.has_content? "needs to be at least 8 characters long" + assert_equal '/signup', current_path + assert_error_for 'srp_password' + end + + def submit_signup_form(username: nil, password: nil, confirmation: nil) username ||= "test_#{SecureRandom.urlsafe_base64}".downcase - password ||= SecureRandom.base64[0,7] + password ||= SecureRandom.base64 + confirmation ||= password visit '/signup' fill_in 'Username', with: username - fill_in 'Password', with: password - fill_in 'Password confirmation', with: password + fill_in 'Password', with: password, match: :prefer_exact + fill_in 'Password confirmation', with: confirmation click_on 'Sign Up' - assert page.has_content? "needs to be at least 8 characters long" - assert_equal '/signup', current_path - assert page.has_selector? ".error #srp_password" end -end + def assert_error_for(id) + assert page.has_selector? ".has-error ##{id}" + end +end diff --git a/test/support/browser_integration_test.rb b/test/support/browser_integration_test.rb index c0fef0a..d00e606 100644 --- a/test/support/browser_integration_test.rb +++ b/test/support/browser_integration_test.rb @@ -36,7 +36,7 @@ class BrowserIntegrationTest < RackStackTest password ||= SecureRandom.base64 visit '/signup' fill_in 'Username', with: username - fill_in 'Password', with: password + fill_in 'Password', with: password, match: :prefer_exact if APP_CONFIG[:invite_required] fill_in 'Invite code', with: @testcode.invite_code end -- cgit v1.2.3