Files
fizzy/test/mailers/account_mailer_test.rb
Stanko Krtalić eceb6c9b43 Add self-service account deletion (#2246)
* Add self-service account deletion

* Disable access to cancelled accounts & implement Stripe interactions

* Add tests

* Fix failing tests

* Remove cancelled accounts from lists

* Fix incorrect redirect

* Use _path instead of _url for consistency

* Don't track how far the inicieration job got

We still want the step tracking so that the job can be interrupted. But, since the scope is idempotent, we don't need to track how far it got.

* Specify the exact time when the data will be deleted

* Fix crash due to unadvancable cursor

* Rename up_for_incineration to due_for_incineration

* Regenrate the schema

* Fix incorrect path check

* Migrate the SQLite schema

* Only show the cancel button on cancellable accounts

* Check that a subscirption method exists before calling it

* Ignore job failures due to missing records when an account gets deleted

* Skip sending notifications on cancelled accounts

* Use collbacks to integrate

* Add a blank line between queue_as and discard_on

* Break checks into methods

* Inline methods

* Rename Account::IncinerateJob

* Run migrations

* Migrate SQLite
2026-01-12 14:21:05 +01:00

58 lines
1.5 KiB
Ruby

require "test_helper"
class AccountMailerTest < ActionMailer::TestCase
setup do
@account = accounts(:"37s")
@user = users(:david)
@account.cancel(initiated_by: @user)
@cancellation = @account.cancellation
end
test "cancellation sends to initiating user" do
email = AccountMailer.cancellation(@cancellation)
assert_emails 1 do
email.deliver_now
end
assert_equal [ @user.identity.email_address ], email.to
end
test "cancellation includes account name" do
email = AccountMailer.cancellation(@cancellation)
assert_match @account.name, email.body.encoded
end
test "cancellation includes support email" do
email = AccountMailer.cancellation(@cancellation)
assert_match "support@fizzy.do", email.body.encoded
end
test "cancellation has correct subject" do
email = AccountMailer.cancellation(@cancellation)
assert_equal "Your Fizzy account was cancelled", email.subject
end
test "cancellation has both HTML and text parts" do
email = AccountMailer.cancellation(@cancellation)
assert email.html_part.present?, "Email should have HTML part"
assert email.text_part.present?, "Email should have text part"
end
test "cancellation mentions account access is removed" do
email = AccountMailer.cancellation(@cancellation)
assert_match /no one can access/i, email.body.encoded
end
test "cancellation mentions data will be deleted" do
email = AccountMailer.cancellation(@cancellation)
assert_match /deleted/i, email.body.encoded
end
end