diff --git a/features/desktop/accepts_invitation.feature b/features/desktop/accepts_invitation.feature index 1be46c6f2..330b58d76 100644 --- a/features/desktop/accepts_invitation.feature +++ b/features/desktop/accepts_invitation.feature @@ -3,11 +3,7 @@ Feature: invitation acceptance Scenario: accept invitation from admin Given I have been invited by an admin And I am on my acceptance form page - And I fill in the following: - | user_username | ohai | - | user_email | woot@sweet.com | - | user_password | secret | - | user_password_confirmation | secret | + And I fill in the new user form And I press "Continue" Then I should be on the getting started page And I should see "Well, hello there!" @@ -21,11 +17,7 @@ Feature: invitation acceptance Scenario: accept invitation from user Given I have been invited by bob And I am on my acceptance form page - And I fill in the following: - | user_username | ohai | - | user_email | woot@sweet.com | - | user_password | secret | - | user_password_confirmation | secret | + And I fill in the new user form And I press "Continue" Then I should be on the getting started page And I should see "Well, hello there!" diff --git a/features/desktop/signs_up.feature b/features/desktop/signs_up.feature index d6f9213b5..606fee713 100644 --- a/features/desktop/signs_up.feature +++ b/features/desktop/signs_up.feature @@ -3,12 +3,7 @@ Feature: new user registration Background: When I go to the new user registration page - And I fill in the following: - | user_username | ohai | - | user_email | ohai@example.com | - | user_password | secret | - | user_password_confirmation | secret | - | user_captcha | 123456 | + And I fill in the new user form And I press "Continue" Then I should be on the getting started page And I should see "Well, hello there!" and "Who are you?" and "What are you into?" @@ -52,16 +47,19 @@ Feature: new user registration And I fill in the following: | user_username | $%&(/&%$&/=)(/ | And I press "Continue" - Then I should see a flash message containing "Email can't be blank - Password can't be blank - Username is invalid." + Then I should not be able to sign up + And I should have a validation error on "user_username, user_password, user_email" When I fill in the following: | user_username | valid_user | | user_email | this is not a valid email $%&/()( | And I press "Continue" - Then I should see a flash message containing "Email is invalid - Password can't be blank" + Then I should not be able to sign up + And I should have a validation error on "user_password, user_email" When I fill in the following: | user_email | valid@email.com | | user_password | 1 | And I press "Continue" - Then I should see a flash message containing "Password doesn't match confirmation - Password is too short (minimum is 6 characters)" + Then I should not be able to sign up + And I should have a validation error on "user_password, user_password_confirmation" diff --git a/features/mobile/getting_started.feature b/features/mobile/getting_started.feature index 4eadd6b63..7dc61e204 100644 --- a/features/mobile/getting_started.feature +++ b/features/mobile/getting_started.feature @@ -3,11 +3,7 @@ Feature: editing the gettig started in the mobile view Scenario: editing gettig started fields When I go to the new user registration page - And I fill in the following: - | user_username | amparito | - | user_email | amp@arito.com | - | user_password | secret | - | user_password_confirmation | secret | + And I fill in the new user form And I press "Continue" And I visit the mobile getting started page And I should see "Well, hello there!" and "Who are you?" and "What are you into?" diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index bab1c44ec..0954c57d1 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -277,3 +277,7 @@ Given /^"([^"]*)" is hidden$/ do |selector| page.should have_selector(selector, visible: false) page.should_not have_selector(selector) end + +Then(/^I should have a validation error on "(.*?)"$/) do |field_list| + check_fields_validation_error field_list +end diff --git a/features/step_definitions/session_steps.rb b/features/step_definitions/session_steps.rb index 6b590e34c..67921bc0a 100644 --- a/features/step_definitions/session_steps.rb +++ b/features/step_definitions/session_steps.rb @@ -58,3 +58,7 @@ end When /^I (?:log|sign) out manually$/ do manual_logout end + +Then(/^I should not be able to sign up$/) do + confirm_not_signed_up +end diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 018949cb6..89f49be03 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -206,10 +206,7 @@ Given /^I visit alice's invitation code url$/ do end When /^I fill in the new user form$/ do - step 'I fill in "user_username" with "ohai"' - step 'I fill in "user_email" with "ohai@example.com"' - step 'I fill in "user_password" with "secret"' - step 'I fill in "user_password_confirmation" with "secret"' + fill_in_new_user_form end And /^I should be able to friend Alice$/ do diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index fa718fe41..49f20ddc2 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -169,8 +169,7 @@ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do | end Then /^(?:|I )should be on (.+)$/ do |page_name| - current_path = URI.parse(current_url).path - current_path.should == path_to(page_name) + confirm_on_page(page_name) end Then /^(?:|I )should have the following query string:$/ do |expected_pairs| diff --git a/features/support/application_cuke_helpers.rb b/features/support/application_cuke_helpers.rb index b7a3b1b35..f2ddb417f 100644 --- a/features/support/application_cuke_helpers.rb +++ b/features/support/application_cuke_helpers.rb @@ -16,6 +16,18 @@ module ApplicationCukeHelpers selector &&= "#flash_#{selector}" find(selector || '.message', {match: :first}.merge(opts)) end + + def confirm_form_validation_error(element) + is_invalid = page.evaluate_script("$('#{element}').is(':invalid')") + is_invalid.should be_true + end + + def check_fields_validation_error(field_list) + field_list.split(',').each do |f| + confirm_form_validation_error('input#'+f.strip) + end + end + end World(ApplicationCukeHelpers) diff --git a/features/support/paths.rb b/features/support/paths.rb index c5d7756bd..1b2fa1790 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -65,6 +65,11 @@ module NavigationHelpers find(await_elem.delete(:selector), await_elem) end end + + def confirm_on_page(page_name) + current_path = URI.parse(current_url).path + current_path.should == path_to(page_name) + end end World(NavigationHelpers) diff --git a/features/support/user_cuke_helpers.rb b/features/support/user_cuke_helpers.rb index 0dc9f0a87..d22185b0a 100644 --- a/features/support/user_cuke_helpers.rb +++ b/features/support/user_cuke_helpers.rb @@ -59,6 +59,17 @@ module UserCukeHelpers find("#user_menu li:last-child a").click end + def fill_in_new_user_form + fill_in('user_username', with: 'ohai') + fill_in('user_email', with: 'ohai@example.com') + fill_in('user_password', with: 'secret') + fill_in('user_password_confirmation', with: 'secret') + + # captcha needs to be filled out, because the field is required (HTML5) + # in test env, the captcha will always pass successfully + fill_in('user_captcha', with: '123456') + end + # fill change password section on the user edit page def fill_change_password_section(cur_pass, new_pass, confirm_pass) fill_in 'user_current_password', :with => cur_pass @@ -87,6 +98,10 @@ module UserCukeHelpers find(".button").click end + def confirm_not_signed_up + confirm_on_page('the new user registration page') + confirm_form_validation_error('form#new_user') + end end World(UserCukeHelpers)