diff --git a/app/views/users/confirmations/new.html.erb b/app/views/users/confirmations/new.html.erb
index 4af186b..16d45ec 100644
--- a/app/views/users/confirmations/new.html.erb
+++ b/app/views/users/confirmations/new.html.erb
@@ -1,16 +1,8 @@
-
Resend confirmation instructions
-
-<%= 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 %>
-
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
-
+ <%= f.email_field :email, required: true, size: 30, autofocus: true, autocomplete: "email",
+ value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
-
- <%= f.submit "Resend confirmation instructions" %>
-
+ <%= f.submit t(:resend_confirmation) %>
<% end %>
-
-<%= render "users/shared/links" %>
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
index 965f08c..981223f 100644
--- a/test/application_system_test_case.rb
+++ b/test/application_system_test_case.rb
@@ -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
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
index 0a5c8db..6099b07 100644
--- a/test/fixtures/users.yml
+++ b/test/fixtures/users.yml
@@ -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:
diff --git a/test/system/users_test.rb b/test/system/users_test.rb
index 79f2ff6..13431e7 100644
--- a/test/system/users_test.rb
+++ b/test/system/users_test.rb
@@ -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