mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Allow users to update their email address (#1745)
* Change email address * Email confirmation * Email change test * Lint * Schema reset * Set test email sender * Select specific user fixture * Refactor/cleanup * Remove unused email_confirmation_token * Current user would never be true * Fix translation test failures
This commit is contained in:
parent
46e86a9a11
commit
41873de11d
28 changed files with 225 additions and 15 deletions
12
test/controllers/email_confirmations_controller_test.rb
Normal file
12
test/controllers/email_confirmations_controller_test.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require "test_helper"
|
||||
|
||||
class EmailConfirmationsControllerTest < ActionDispatch::IntegrationTest
|
||||
test "should get confirm" do
|
||||
user = users(:new_email)
|
||||
user.update!(unconfirmed_email: "new@example.com")
|
||||
token = user.generate_token_for(:email_confirmation)
|
||||
|
||||
get new_email_confirmation_path(token: token)
|
||||
assert_redirected_to new_session_path
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@ class TransactionsControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
test "transaction count represents filtered total" do
|
||||
family = families(:empty)
|
||||
sign_in family.users.first
|
||||
sign_in users(:empty)
|
||||
account = family.accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Depository.new
|
||||
|
||||
3.times do
|
||||
|
@ -32,7 +32,7 @@ class TransactionsControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
test "can paginate" do
|
||||
family = families(:empty)
|
||||
sign_in family.users.first
|
||||
sign_in users(:empty)
|
||||
account = family.accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Depository.new
|
||||
|
||||
11.times do
|
||||
|
|
11
test/fixtures/users.yml
vendored
11
test/fixtures/users.yml
vendored
|
@ -30,4 +30,13 @@ family_member:
|
|||
last_name: Dylan
|
||||
email: jakobdylan@yahoo.com
|
||||
password_digest: <%= BCrypt::Password.create('password') %>
|
||||
onboarded_at: <%= 3.days.ago %>
|
||||
onboarded_at: <%= 3.days.ago %>
|
||||
|
||||
new_email:
|
||||
family: empty
|
||||
first_name: Test
|
||||
last_name: User
|
||||
email: user@example.com
|
||||
unconfirmed_email: new@example.com
|
||||
password_digest: <%= BCrypt::Password.create('password123') %>
|
||||
onboarded_at: <%= Time.current %>
|
14
test/mailers/email_confirmation_mailer_test.rb
Normal file
14
test/mailers/email_confirmation_mailer_test.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require "test_helper"
|
||||
|
||||
class EmailConfirmationMailerTest < ActionMailer::TestCase
|
||||
test "confirmation_email" do
|
||||
user = users(:new_email)
|
||||
user.unconfirmed_email = "new@example.com"
|
||||
|
||||
mail = EmailConfirmationMailer.with(user: user).confirmation_email
|
||||
assert_equal I18n.t("email_confirmation_mailer.confirmation_email.subject"), mail.subject
|
||||
assert_equal [ user.unconfirmed_email ], mail.to
|
||||
assert_equal [ "hello@maybefinance.com" ], mail.from
|
||||
assert_match "confirm", mail.body.encoded
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
# Preview all emails at http://localhost:3000/rails/mailers/email_confirmation_mailer
|
||||
class EmailConfirmationMailerPreview < ActionMailer::Preview
|
||||
# Preview this email at http://localhost:3000/rails/mailers/email_confirmation_mailer/confirmation_email
|
||||
def confirmation_email
|
||||
EmailConfirmationMailer.confirmation_email
|
||||
end
|
||||
end
|
|
@ -38,8 +38,8 @@ class UserTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test "email address is normalized" do
|
||||
@user.update!(email: " User@ExAMPle.CoM ")
|
||||
assert_equal "user@example.com", @user.reload.email
|
||||
@user.update!(email: " UNIQUE-User@ExAMPle.CoM ")
|
||||
assert_equal "unique-user@example.com", @user.reload.email
|
||||
end
|
||||
|
||||
test "display name" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue