forked from fixin.me/fixin.me
Update and test resend confirmation form
This commit is contained in:
parent
7dabbd3036
commit
30a3ecd6d0
@ -1,16 +1,8 @@
|
||||
<h2>Resend confirmation instructions</h2>
|
||||
|
||||
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
|
||||
<%= tabular_form_for resource, url: user_confirmation_path, html: { method: :post } do |f| %>
|
||||
<%= render "users/shared/error_messages", resource: resource %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :email %><br />
|
||||
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
|
||||
</div>
|
||||
<%= f.email_field :email, required: true, size: 30, autofocus: true, autocomplete: "email",
|
||||
value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit "Resend confirmation instructions" %>
|
||||
</div>
|
||||
<%= f.submit t(:resend_confirmation) %>
|
||||
<% end %>
|
||||
|
||||
<%= render "users/shared/links" %>
|
||||
|
@ -6,7 +6,7 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||
|
||||
driven_by :selenium, using: :headless_firefox, screen_size: [1600, 900]
|
||||
|
||||
def sign_in(user: users.sample, password: randomize_user_password!(user))
|
||||
def sign_in(user: users.select(&:confirmed?).sample, password: randomize_user_password!(user))
|
||||
visit new_user_session_url
|
||||
fill_in User.human_attribute_name(:email).capitalize, with: user.email
|
||||
fill_in User.human_attribute_name(:password).capitalize, with: password
|
||||
|
10
test/fixtures/users.yml
vendored
10
test/fixtures/users.yml
vendored
@ -3,3 +3,13 @@ admin:
|
||||
status: admin
|
||||
encrypted_password: <%= Devise::Encryptor.digest(User, 'admin') %>
|
||||
confirmed_at: <%= DateTime.now %>
|
||||
alice:
|
||||
email: alice@example.com
|
||||
status: active
|
||||
encrypted_password: <%= Devise::Encryptor.digest(User, 'alice') %>
|
||||
confirmed_at: <%= DateTime.now - 7.days %>
|
||||
bob:
|
||||
email: bob@gmail.com
|
||||
status: active
|
||||
encrypted_password: <%= Devise::Encryptor.digest(User, 'bob') %>
|
||||
confirmed_at:
|
||||
|
@ -25,6 +25,31 @@ class UsersTest < ApplicationSystemTestCase
|
||||
assert_text t('devise.sessions.signed_out')
|
||||
end
|
||||
|
||||
test "recover password" do
|
||||
visit new_user_session_url
|
||||
click_link t(:recover_password)
|
||||
|
||||
fill_in User.human_attribute_name(:email).capitalize,
|
||||
with: users.select(&:confirmed?).sample.email
|
||||
assert_emails 1 do
|
||||
click_on t(:recover_password)
|
||||
end
|
||||
assert_current_path new_user_session_path
|
||||
assert_text t('devise.passwords.send_instructions')
|
||||
|
||||
with_last_email do |mail|
|
||||
visit Capybara.string(mail.body.to_s).find_link("Change my password")[:href]
|
||||
end
|
||||
new_password = random_password
|
||||
fill_in t('users.passwords.edit.new_password'), with: new_password
|
||||
fill_in t('users.passwords.edit.password_confirmation'), with: new_password
|
||||
assert_emails 1 do
|
||||
click_on t('users.passwords.edit.update_password')
|
||||
end
|
||||
assert_no_current_path user_password_path
|
||||
assert_text t('devise.passwords.updated')
|
||||
end
|
||||
|
||||
test "register" do
|
||||
visit new_user_session_url
|
||||
click_link t(:register)
|
||||
@ -50,27 +75,21 @@ class UsersTest < ApplicationSystemTestCase
|
||||
assert User.last.confirmed?
|
||||
end
|
||||
|
||||
test "recover password" do
|
||||
test "resend confirmation" do
|
||||
visit new_user_session_url
|
||||
click_link t(:recover_password)
|
||||
click_link t(:register)
|
||||
click_link t(:resend_confirmation)
|
||||
|
||||
fill_in User.human_attribute_name(:email).capitalize, with: users.sample.email
|
||||
fill_in User.human_attribute_name(:email).capitalize,
|
||||
with: users.reject(&:confirmed?).sample.email
|
||||
assert_emails 1 do
|
||||
click_on t(:recover_password)
|
||||
click_on t(:resend_confirmation)
|
||||
end
|
||||
assert_current_path new_user_session_path
|
||||
assert_text t('devise.passwords.send_instructions')
|
||||
assert_text t('devise.confirmations.send_instructions')
|
||||
|
||||
with_last_email do |mail|
|
||||
visit Capybara.string(mail.body.to_s).find_link("Change my password")[:href]
|
||||
visit Capybara.string(mail.body.to_s).find_link("Confirm my account")[:href]
|
||||
end
|
||||
new_password = random_password
|
||||
fill_in t('users.passwords.edit.new_password'), with: new_password
|
||||
fill_in t('users.passwords.edit.password_confirmation'), with: new_password
|
||||
assert_emails 1 do
|
||||
click_on t('users.passwords.edit.update_password')
|
||||
end
|
||||
assert_no_current_path user_password_path
|
||||
assert_text t('devise.passwords.updated')
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user