Validate uniqueness of user email address
* Make user.email attribute unique * Render validations error messages in users/new view
This commit is contained in:
12
features/step_definitions/user_step.rb
Normal file
12
features/step_definitions/user_step.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
Given /^a user with "([^"]*)" email address exists$/ do |email|
|
||||
Factory.create(:user, :email => email)
|
||||
end
|
||||
|
||||
When /^I register with "([^"]*)" email address$/ do |email|
|
||||
visit new_user_path
|
||||
user = Factory.build(:user)
|
||||
fill_in('Email', :with => email)
|
||||
fill_in('Password', :with => user.password)
|
||||
fill_in('Password confirmation', :with => user.password)
|
||||
click_button('Sign up')
|
||||
end
|
@@ -9,3 +9,8 @@ Feature: User
|
||||
When I follow the sign up link
|
||||
And I fill in the sign up form
|
||||
Then I should be redirected to the home page
|
||||
|
||||
Scenario: User can't register twice with the same email address
|
||||
Given a user with "unique@example.net" email address exists
|
||||
When I register with "unique@example.net" email address
|
||||
Then I should see "Email has already been taken"
|
||||
|
Reference in New Issue
Block a user