Add registerable integration tests.
This commit is contained in:
parent
732e31528e
commit
1b6f1b9752
|
@ -18,8 +18,8 @@
|
|||
<p><%= f.submit "Update" %></p>
|
||||
<% end -%>
|
||||
|
||||
<h3>Cancel your account</h3>
|
||||
<h3>Cancel my account</h3>
|
||||
|
||||
<p>Unhappy? <%= link_to "Cancel your account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %></p>
|
||||
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
|
||||
|
||||
<%= render :partial => "shared/devise_links" %>
|
||||
|
|
|
@ -21,10 +21,7 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
end
|
||||
|
||||
test 'a guest user should be able to sign up successfully and be blocked by confirmation' do
|
||||
visit new_user_session_path
|
||||
click_link 'Sign up'
|
||||
|
||||
assert_template 'registrations/new'
|
||||
visit new_user_registration_path
|
||||
|
||||
fill_in 'email', :with => 'new_user@test.com'
|
||||
fill_in 'password', :with => 'new_user123'
|
||||
|
@ -49,8 +46,7 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
end
|
||||
|
||||
test 'a guest user cannot sign up with invalid information' do
|
||||
visit new_user_session_path
|
||||
click_link 'Sign up'
|
||||
visit new_user_registration_path
|
||||
|
||||
fill_in 'email', :with => 'invalid_email'
|
||||
fill_in 'password', :with => 'new_user123'
|
||||
|
@ -68,9 +64,7 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
|
||||
test 'a guest should not sign up with email/password that already exists' do
|
||||
user = create_user
|
||||
|
||||
visit new_user_session_path
|
||||
click_link 'Sign up'
|
||||
visit new_user_registration_path
|
||||
|
||||
fill_in 'email', :with => 'user@test.com'
|
||||
fill_in 'password', :with => '123456'
|
||||
|
@ -82,4 +76,55 @@ class RegistrationTest < ActionController::IntegrationTest
|
|||
|
||||
assert_not warden.authenticated?(:user)
|
||||
end
|
||||
end
|
||||
|
||||
test 'a guest should not be able to change account' do
|
||||
visit edit_user_registration_path
|
||||
follow_redirect!
|
||||
assert_template 'sessions/new'
|
||||
end
|
||||
|
||||
test 'a signed in user should not be able to access sign up' do
|
||||
sign_in_as_user
|
||||
visit new_user_registration_path
|
||||
assert_template 'home/index'
|
||||
end
|
||||
|
||||
test 'a signed in user should be able to edit his account' do
|
||||
sign_in_as_user
|
||||
visit edit_user_registration_path
|
||||
|
||||
fill_in 'email', :with => 'user.new@email.com'
|
||||
fill_in 'current password', :with => '123456'
|
||||
click_button 'Update'
|
||||
|
||||
assert_template 'home/index'
|
||||
assert_contain 'You updated your account successfully.'
|
||||
|
||||
assert_equal "user.new@email.com", User.first.email
|
||||
end
|
||||
|
||||
test 'a signed in user should be able to edit his password' do
|
||||
sign_in_as_user
|
||||
visit edit_user_registration_path
|
||||
|
||||
fill_in 'password', :with => 'pas123'
|
||||
fill_in 'password confirmation', :with => 'pas123'
|
||||
fill_in 'current password', :with => '123456'
|
||||
click_button 'Update'
|
||||
|
||||
assert_template 'home/index'
|
||||
assert_contain 'You updated your account successfully.'
|
||||
|
||||
assert User.first.valid_password?('pas123')
|
||||
end
|
||||
|
||||
test 'a signed in user should be able to cancel his account' do
|
||||
sign_in_as_user
|
||||
visit edit_user_registration_path
|
||||
|
||||
click_link "Cancel my account"
|
||||
assert_contain "Bye! Your account was successfully cancelled. We hope to see you again soon."
|
||||
|
||||
assert User.all.empty?
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue