diff options
Diffstat (limited to 'actionmailer/test/mailers')
-rw-r--r-- | actionmailer/test/mailers/asset_mailer.rb | 4 | ||||
-rw-r--r-- | actionmailer/test/mailers/base_mailer.rb | 42 | ||||
-rw-r--r-- | actionmailer/test/mailers/caching_mailer.rb | 10 | ||||
-rw-r--r-- | actionmailer/test/mailers/delayed_mailer.rb | 24 | ||||
-rw-r--r-- | actionmailer/test/mailers/params_mailer.rb | 13 | ||||
-rw-r--r-- | actionmailer/test/mailers/proc_mailer.rb | 15 |
6 files changed, 79 insertions, 29 deletions
diff --git a/actionmailer/test/mailers/asset_mailer.rb b/actionmailer/test/mailers/asset_mailer.rb index f54a50d00d..7a9aba2629 100644 --- a/actionmailer/test/mailers/asset_mailer.rb +++ b/actionmailer/test/mailers/asset_mailer.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + class AssetMailer < ActionMailer::Base self.mailer_name = "asset_mailer" def welcome - mail + mail end end diff --git a/actionmailer/test/mailers/base_mailer.rb b/actionmailer/test/mailers/base_mailer.rb index 8c2225ce60..bfaecdb658 100644 --- a/actionmailer/test/mailers/base_mailer.rb +++ b/actionmailer/test/mailers/base_mailer.rb @@ -1,13 +1,15 @@ +# frozen_string_literal: true + class BaseMailer < ActionMailer::Base self.mailer_name = "base_mailer" - default to: 'system@test.lindsaar.net', - from: 'jose@test.plataformatec.com', - reply_to: 'mikel@test.lindsaar.net' + default to: "system@test.lindsaar.net", + from: "jose@test.plataformatec.com", + reply_to: "mikel@test.lindsaar.net" def welcome(hash = {}) - headers['X-SPAM'] = "Not SPAM" - mail({subject: "The first email on new API!"}.merge!(hash)) + headers["X-SPAM"] = "Not SPAM" + mail({ subject: "The first email on new API!" }.merge!(hash)) end def welcome_with_headers(hash = {}) @@ -28,30 +30,30 @@ class BaseMailer < ActionMailer::Base end def inline_attachment - attachments.inline['logo.png'] = "\312\213\254\232" + attachments.inline["logo.png"] = "\312\213\254\232" mail end def attachment_with_content(hash = {}) - attachments['invoice.pdf'] = 'This is test File content' + attachments["invoice.pdf"] = "This is test File content" mail(hash) end def attachment_with_hash - attachments['invoice.jpg'] = { data: ::Base64.encode64("\312\213\254\232)b"), + attachments["invoice.jpg"] = { data: ::Base64.encode64("\312\213\254\232)b"), mime_type: "image/x-jpg", transfer_encoding: "base64" } mail end def attachment_with_hash_default_encoding - attachments['invoice.jpg'] = { data: "\312\213\254\232)b", + attachments["invoice.jpg"] = { data: "\312\213\254\232)b", mime_type: "image/x-jpg" } mail end def implicit_multipart(hash = {}) - attachments['invoice.pdf'] = 'This is test File content' if hash.delete(:attachments) + attachments["invoice.pdf"] = "This is test File content" if hash.delete(:attachments) mail(hash) end @@ -60,10 +62,10 @@ class BaseMailer < ActionMailer::Base end def explicit_multipart(hash = {}) - attachments['invoice.pdf'] = 'This is test File content' if hash.delete(:attachments) + attachments["invoice.pdf"] = "This is test File content" if hash.delete(:attachments) mail(hash) do |format| - format.text { render text: "TEXT Explicit Multipart" } - format.html { render text: "HTML Explicit Multipart" } + format.text { render plain: "TEXT Explicit Multipart" } + format.html { render plain: "HTML Explicit Multipart" } end end @@ -76,7 +78,7 @@ class BaseMailer < ActionMailer::Base def explicit_multipart_with_any(hash = {}) mail(hash) do |format| - format.any(:text, :html){ render text: "Format with any!" } + format.any(:text, :html) { render plain: "Format with any!" } end end @@ -88,8 +90,8 @@ class BaseMailer < ActionMailer::Base def explicit_multipart_with_options(include_html = false) mail do |format| - format.text(content_transfer_encoding: "base64"){ render "welcome" } - format.html{ render "welcome" } if include_html + format.text(content_transfer_encoding: "base64") { render "welcome" } + format.html { render "welcome" } if include_html end end @@ -100,18 +102,18 @@ class BaseMailer < ActionMailer::Base end end - def implicit_different_template(template_name='') + def implicit_different_template(template_name = "") mail(template_name: template_name) end - def explicit_different_template(template_name='') + def explicit_different_template(template_name = "") mail do |format| format.text { render template: "#{mailer_name}/#{template_name}" } format.html { render template: "#{mailer_name}/#{template_name}" } end end - def different_layout(layout_name='') + def different_layout(layout_name = "") mail do |format| format.text { render layout: layout_name } format.html { render layout: layout_name } @@ -131,6 +133,6 @@ class BaseMailer < ActionMailer::Base end def with_subject_interpolations - mail(subject: default_i18n_subject(rapper_or_impersonator: 'Slim Shady'), body: '') + mail(subject: default_i18n_subject(rapper_or_impersonator: "Slim Shady"), body: "") end end diff --git a/actionmailer/test/mailers/caching_mailer.rb b/actionmailer/test/mailers/caching_mailer.rb index 345d267a36..02f0c6c103 100644 --- a/actionmailer/test/mailers/caching_mailer.rb +++ b/actionmailer/test/mailers/caching_mailer.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CachingMailer < ActionMailer::Base self.mailer_name = "caching_mailer" @@ -12,4 +14,12 @@ class CachingMailer < ActionMailer::Base def skip_fragment_cache_digesting mail(subject: "welcome", template_name: "skip_fragment_cache_digesting") end + + def fragment_caching_options + mail(subject: "welcome", template_name: "fragment_caching_options") + end + + def multipart_cache + mail(subject: "welcome", template_name: "multipart_cache") + end end diff --git a/actionmailer/test/mailers/delayed_mailer.rb b/actionmailer/test/mailers/delayed_mailer.rb index 62d4baa434..b0f5ecc2fb 100644 --- a/actionmailer/test/mailers/delayed_mailer.rb +++ b/actionmailer/test/mailers/delayed_mailer.rb @@ -1,6 +1,28 @@ +# frozen_string_literal: true + +require "active_job/arguments" + +class DelayedMailerError < StandardError; end + class DelayedMailer < ActionMailer::Base + cattr_accessor :last_error + cattr_accessor :last_rescue_from_instance + + rescue_from DelayedMailerError do |error| + @@last_error = error + @@last_rescue_from_instance = self + end + + rescue_from ActiveJob::DeserializationError do |error| + @@last_error = error + @@last_rescue_from_instance = self + end def test_message(*) - mail(from: 'test-sender@test.com', to: 'test-receiver@test.com', subject: 'Test Subject', body: 'Test Body') + mail(from: "test-sender@test.com", to: "test-receiver@test.com", subject: "Test Subject", body: "Test Body") + end + + def test_raise(klass_name) + raise klass_name.constantize, "boom" end end diff --git a/actionmailer/test/mailers/params_mailer.rb b/actionmailer/test/mailers/params_mailer.rb new file mode 100644 index 0000000000..84aa336311 --- /dev/null +++ b/actionmailer/test/mailers/params_mailer.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class ParamsMailer < ActionMailer::Base + before_action { @inviter, @invitee = params[:inviter], params[:invitee] } + + default to: Proc.new { @invitee }, from: -> { @inviter } + + def invitation + mail(subject: "Welcome to the project!") do |format| + format.text { render plain: "So says #{@inviter}" } + end + end +end diff --git a/actionmailer/test/mailers/proc_mailer.rb b/actionmailer/test/mailers/proc_mailer.rb index 7e189d861f..b7cf53eb4a 100644 --- a/actionmailer/test/mailers/proc_mailer.rb +++ b/actionmailer/test/mailers/proc_mailer.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + class ProcMailer < ActionMailer::Base - default to: 'system@test.lindsaar.net', - 'X-Proc-Method' => Proc.new { Time.now.to_i.to_s }, + default to: "system@test.lindsaar.net", + "X-Proc-Method" => Proc.new { Time.now.to_i.to_s }, subject: Proc.new { give_a_greeting }, - 'x-has-to-proc' => :symbol + "x-has-to-proc" => :symbol def welcome mail @@ -10,8 +12,7 @@ class ProcMailer < ActionMailer::Base private - def give_a_greeting - "Thanks for signing up this afternoon" - end - + def give_a_greeting + "Thanks for signing up this afternoon" + end end |