Kaynağa Gözat

Fix failure when sending warning emails with custom text (#17983)

* Add tests

* Fix failure when sending warning emails with custom text
Claire 2 yıl önce
ebeveyn
işleme
ce9dcbea32
2 değiştirilmiş dosya ile 12 ekleme ve 0 silme
  1. 1 0
      app/mailers/user_mailer.rb
  2. 11 0
      spec/mailers/user_mailer_spec.rb

+ 1 - 0
app/mailers/user_mailer.rb

@@ -7,6 +7,7 @@ class UserMailer < Devise::Mailer
   helper :application
   helper :instance
   helper :statuses
+  helper :formatting
 
   helper RoutingHelper
 

+ 11 - 0
spec/mailers/user_mailer_spec.rb

@@ -83,4 +83,15 @@ describe UserMailer, type: :mailer do
     include_examples 'localized subject',
                      'devise.mailer.email_changed.subject'
   end
+
+  describe 'warning' do
+    let(:strike) { Fabricate(:account_warning, target_account: receiver.account, text: 'dont worry its just the testsuite', action: 'suspend') }
+    let(:mail)   { UserMailer.warning(receiver, strike) }
+
+    it 'renders warning notification' do
+      receiver.update!(locale: nil)
+      expect(mail.body.encoded).to include I18n.t("user_mailer.warning.title.suspend", acct: receiver.account.acct)
+      expect(mail.body.encoded).to include strike.text
+    end
+  end
 end