fix client-side validations in registration form + test

This commit is contained in:
Florian Staudacher 2012-06-18 14:47:29 +02:00
parent f3d983151b
commit 994bfd4a24
5 changed files with 38 additions and 1 deletions

View file

@ -19,7 +19,7 @@
<%= t('.sign_up') %> <%= t('.sign_up') %>
</h4> </h4>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => "form-horizontal block-form", :autocomplete => "off"}, :validate => true) do |f| %> <%= form_for(resource, :validate => true, :url => registration_path(resource_name), :html => {:class => "form-horizontal block-form", :autocomplete => "off"}) do |f| %>
<fieldset> <fieldset>
<div class="control-group"> <div class="control-group">
<label class="control-label" for="user_email"> <label class="control-label" for="user_email">

View file

@ -36,3 +36,26 @@ Feature: new user registration
And I wait for 3 seconds And I wait for 3 seconds
And I go to the home page And I go to the home page
Then I should not see "Welcome to Diaspora" Then I should not see "Welcome to Diaspora"
Scenario: user fills in bogus data - client side validation
When I log out manually
And I go to the new user registration page
And I fill in "user_username" with "§$%&(/&%$&/=)(/"
And I press "Continue"
Then the "user_username" field should have a validation error
And the "user_email" field should have a validation error
And the "user_password" field should have a validation error
When I fill in "user_username" with "valid_user"
And I fill in "user_email" with "this is not a valid email $%&/()("
And I press "Continue"
Then the "user_email" field should have a validation error
And the "user_password" field should have a validation error
When I fill in "user_email" with "valid@email.com"
And I fill in "user_password" with "1"
And I press "Continue"
Then the "user_password" field should have a validation error

View file

@ -8,6 +8,10 @@ And /^I submit the form$/ do
click_button :submit click_button :submit
end end
Then /^the "([^"]*)" field should have a validation error$/ do |field|
find_field(field).has_xpath?(".//ancestor::div[contains(@class, 'control-group')]/div[contains(@class, 'field_with_errors')]")
end
And /^I expand the publisher$/ do And /^I expand the publisher$/ do
click_publisher click_publisher
end end

View file

@ -39,3 +39,7 @@ end
When /^I (?:log|sign) out$/ do When /^I (?:log|sign) out$/ do
logout logout
end end
When /^I (?:log|sign) out manually$/ do
manual_logout
end

View file

@ -42,6 +42,7 @@ module UserCukeHelpers
login_as @me.username, @me.password login_as @me.username, @me.password
end end
# checks the page content to see, if the login was successful
def confirm_login def confirm_login
wait_until { page.has_content?("#{@me.first_name} #{@me.last_name}") } wait_until { page.has_content?("#{@me.first_name} #{@me.last_name}") }
end end
@ -51,6 +52,11 @@ module UserCukeHelpers
$browser.delete_cookie('_session', 'path=/') if $browser $browser.delete_cookie('_session', 'path=/') if $browser
$browser.delete_all_visible_cookies if $browser $browser.delete_all_visible_cookies if $browser
end end
def manual_logout
find("#user_menu li:first-child a").click
find("#user_menu li:last-child a").click
end
end end
World(UserCukeHelpers) World(UserCukeHelpers)