actionmailer 3.2.9 → 6.1.7.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionmailer might be problematic. Click here for more details.

@@ -1,45 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_job"
4
+
1
5
  module ActionMailer
6
+ # Provides helper methods for testing Action Mailer, including #assert_emails
7
+ # and #assert_no_emails.
2
8
  module TestHelper
3
- extend ActiveSupport::Concern
9
+ include ActiveJob::TestHelper
4
10
 
5
11
  # Asserts that the number of emails sent matches the given number.
6
12
  #
7
13
  # def test_emails
8
14
  # assert_emails 0
9
- # ContactMailer.deliver_contact
15
+ # ContactMailer.welcome.deliver_now
10
16
  # assert_emails 1
11
- # ContactMailer.deliver_contact
17
+ # ContactMailer.welcome.deliver_now
12
18
  # assert_emails 2
13
19
  # end
14
20
  #
15
- # If a block is passed, that block should cause the specified number of emails to be sent.
21
+ # If a block is passed, that block should cause the specified number of
22
+ # emails to be sent.
16
23
  #
17
24
  # def test_emails_again
18
25
  # assert_emails 1 do
19
- # ContactMailer.deliver_contact
26
+ # ContactMailer.welcome.deliver_now
20
27
  # end
21
28
  #
22
29
  # assert_emails 2 do
23
- # ContactMailer.deliver_contact
24
- # ContactMailer.deliver_contact
30
+ # ContactMailer.welcome.deliver_now
31
+ # ContactMailer.welcome.deliver_later
25
32
  # end
26
33
  # end
27
- def assert_emails(number)
34
+ def assert_emails(number, &block)
28
35
  if block_given?
29
36
  original_count = ActionMailer::Base.deliveries.size
30
- yield
37
+ perform_enqueued_jobs(only: ->(job) { delivery_job_filter(job) }, &block)
31
38
  new_count = ActionMailer::Base.deliveries.size
32
- assert_equal original_count + number, new_count, "#{number} emails expected, but #{new_count - original_count} were sent"
39
+ assert_equal number, new_count - original_count, "#{number} emails expected, but #{new_count - original_count} were sent"
33
40
  else
34
41
  assert_equal number, ActionMailer::Base.deliveries.size
35
42
  end
36
43
  end
37
44
 
38
- # Assert that no emails have been sent.
45
+ # Asserts that no emails have been sent.
39
46
  #
40
47
  # def test_emails
41
48
  # assert_no_emails
42
- # ContactMailer.deliver_contact
49
+ # ContactMailer.welcome.deliver_now
43
50
  # assert_emails 1
44
51
  # end
45
52
  #
@@ -53,9 +60,103 @@ module ActionMailer
53
60
  #
54
61
  # Note: This assertion is simply a shortcut for:
55
62
  #
56
- # assert_emails 0
63
+ # assert_emails 0, &block
57
64
  def assert_no_emails(&block)
58
65
  assert_emails 0, &block
59
66
  end
67
+
68
+ # Asserts that the number of emails enqueued for later delivery matches
69
+ # the given number.
70
+ #
71
+ # def test_emails
72
+ # assert_enqueued_emails 0
73
+ # ContactMailer.welcome.deliver_later
74
+ # assert_enqueued_emails 1
75
+ # ContactMailer.welcome.deliver_later
76
+ # assert_enqueued_emails 2
77
+ # end
78
+ #
79
+ # If a block is passed, that block should cause the specified number of
80
+ # emails to be enqueued.
81
+ #
82
+ # def test_emails_again
83
+ # assert_enqueued_emails 1 do
84
+ # ContactMailer.welcome.deliver_later
85
+ # end
86
+ #
87
+ # assert_enqueued_emails 2 do
88
+ # ContactMailer.welcome.deliver_later
89
+ # ContactMailer.welcome.deliver_later
90
+ # end
91
+ # end
92
+ def assert_enqueued_emails(number, &block)
93
+ assert_enqueued_jobs(number, only: ->(job) { delivery_job_filter(job) }, &block)
94
+ end
95
+
96
+ # Asserts that a specific email has been enqueued, optionally
97
+ # matching arguments.
98
+ #
99
+ # def test_email
100
+ # ContactMailer.welcome.deliver_later
101
+ # assert_enqueued_email_with ContactMailer, :welcome
102
+ # end
103
+ #
104
+ # def test_email_with_arguments
105
+ # ContactMailer.welcome("Hello", "Goodbye").deliver_later
106
+ # assert_enqueued_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"]
107
+ # end
108
+ #
109
+ # If a block is passed, that block should cause the specified email
110
+ # to be enqueued.
111
+ #
112
+ # def test_email_in_block
113
+ # assert_enqueued_email_with ContactMailer, :welcome do
114
+ # ContactMailer.welcome.deliver_later
115
+ # end
116
+ # end
117
+ #
118
+ # If +args+ is provided as a Hash, a parameterized email is matched.
119
+ #
120
+ # def test_parameterized_email
121
+ # assert_enqueued_email_with ContactMailer, :welcome,
122
+ # args: {email: 'user@example.com'} do
123
+ # ContactMailer.with(email: 'user@example.com').welcome.deliver_later
124
+ # end
125
+ # end
126
+ def assert_enqueued_email_with(mailer, method, args: nil, queue: ActionMailer::Base.deliver_later_queue_name || "default", &block)
127
+ args = if args.is_a?(Hash)
128
+ [mailer.to_s, method.to_s, "deliver_now", params: args, args: []]
129
+ else
130
+ [mailer.to_s, method.to_s, "deliver_now", args: Array(args)]
131
+ end
132
+ assert_enqueued_with(job: mailer.delivery_job, args: args, queue: queue.to_s, &block)
133
+ end
134
+
135
+ # Asserts that no emails are enqueued for later delivery.
136
+ #
137
+ # def test_no_emails
138
+ # assert_no_enqueued_emails
139
+ # ContactMailer.welcome.deliver_later
140
+ # assert_enqueued_emails 1
141
+ # end
142
+ #
143
+ # If a block is provided, it should not cause any emails to be enqueued.
144
+ #
145
+ # def test_no_emails
146
+ # assert_no_enqueued_emails do
147
+ # # No emails should be enqueued from this block
148
+ # end
149
+ # end
150
+ def assert_no_enqueued_emails(&block)
151
+ assert_enqueued_emails 0, &block
152
+ end
153
+
154
+ private
155
+ def delivery_job_filter(job)
156
+ job_class = job.is_a?(Hash) ? job.fetch(:job) : job.class
157
+
158
+ Base.descendants.map(&:delivery_job).include?(job_class) ||
159
+ ActionMailer::Parameterized::DeliveryJob == job_class
160
+ end
60
161
  end
61
162
  end
@@ -1,10 +1,11 @@
1
- module ActionMailer
2
- module VERSION #:nodoc:
3
- MAJOR = 3
4
- MINOR = 2
5
- TINY = 9
6
- PRE = nil
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "gem_version"
7
4
 
8
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
5
+ module ActionMailer
6
+ # Returns the version of the currently loaded Action Mailer as a
7
+ # <tt>Gem::Version</tt>.
8
+ def self.version
9
+ gem_version
9
10
  end
10
11
  end
data/lib/action_mailer.rb CHANGED
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  #--
2
- # Copyright (c) 2004-2011 David Heinemeier Hansson
4
+ # Copyright (c) 2004-2022 David Heinemeier Hansson
3
5
  #
4
6
  # Permission is hereby granted, free of charge, to any person obtaining
5
7
  # a copy of this software and associated documentation files (the
@@ -21,29 +23,49 @@
21
23
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
24
  #++
23
25
 
24
- actionpack_path = File.expand_path('../../../actionpack/lib', __FILE__)
25
- $:.unshift(actionpack_path) if File.directory?(actionpack_path) && !$:.include?(actionpack_path)
26
-
27
- require 'abstract_controller'
28
- require 'action_view'
29
- require 'action_mailer/version'
26
+ require "abstract_controller"
27
+ require "action_mailer/version"
30
28
 
31
29
  # Common Active Support usage in Action Mailer
32
- require 'active_support/core_ext/class'
33
- require 'active_support/core_ext/object/blank'
34
- require 'active_support/core_ext/array/uniq_by'
35
- require 'active_support/core_ext/module/attr_internal'
36
- require 'active_support/core_ext/module/delegation'
37
- require 'active_support/core_ext/string/inflections'
38
- require 'active_support/lazy_load_hooks'
30
+ require "active_support"
31
+ require "active_support/rails"
32
+ require "active_support/core_ext/class"
33
+ require "active_support/core_ext/module/attr_internal"
34
+ require "active_support/core_ext/string/inflections"
35
+ require "active_support/lazy_load_hooks"
39
36
 
40
37
  module ActionMailer
41
38
  extend ::ActiveSupport::Autoload
42
39
 
43
- autoload :Collector
40
+ eager_autoload do
41
+ autoload :Collector
42
+ end
43
+
44
44
  autoload :Base
45
45
  autoload :DeliveryMethods
46
+ autoload :InlinePreviewInterceptor
46
47
  autoload :MailHelper
48
+ autoload :Parameterized
49
+ autoload :Preview
50
+ autoload :Previews, "action_mailer/preview"
47
51
  autoload :TestCase
48
52
  autoload :TestHelper
53
+ autoload :MessageDelivery
54
+ autoload :DeliveryJob
55
+ autoload :MailDeliveryJob
56
+
57
+ def self.eager_load!
58
+ super
59
+
60
+ require "action_mailer/mail_with_error_handling"
61
+ Mail.eager_autoload!
62
+ end
63
+ end
64
+
65
+ autoload :Mime, "action_dispatch/http/mime_type"
66
+
67
+ ActiveSupport.on_load(:action_view) do
68
+ ActionView::Base.default_formats ||= Mime::SET.symbols
69
+ ActionView::Template::Types.delegate_to Mime
70
+ ActionView::LookupContext::DetailsKey.clear
49
71
  end
@@ -1,6 +1,6 @@
1
1
  Description:
2
2
  ============
3
- Stubs out a new mailer and its views. Pass the mailer name, either
3
+ Generates a new mailer and its views. Passes the mailer name, either
4
4
  CamelCased or under_scored, and an optional list of emails as arguments.
5
5
 
6
6
  This generates a mailer class in app/mailers and invokes your template
@@ -8,11 +8,9 @@ Description:
8
8
 
9
9
  Example:
10
10
  ========
11
- rails generate mailer Notifications signup forgot_password invoice
12
-
13
- creates a Notifications mailer class, views, test, and fixtures:
14
- Mailer: app/mailers/notifications.rb
15
- Views: app/views/notifications/signup.erb [...]
16
- Test: test/functional/notifications_test.rb
17
- Fixtures: test/fixtures/notifications/signup [...]
11
+ bin/rails generate mailer Notifications signup forgot_password invoice
18
12
 
13
+ creates a Notifications mailer class, views, and test:
14
+ Mailer: app/mailers/notifications_mailer.rb
15
+ Views: app/views/notifications_mailer/signup.text.erb [...]
16
+ Test: test/mailers/notifications_mailer_test.rb
@@ -1,16 +1,38 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Rails
2
4
  module Generators
3
5
  class MailerGenerator < NamedBase
4
- source_root File.expand_path("../templates", __FILE__)
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ argument :actions, type: :array, default: [], banner: "method method"
5
9
 
6
- argument :actions, :type => :array, :default => [], :banner => "method method"
7
- check_class_collision
10
+ check_class_collision suffix: "Mailer"
8
11
 
9
12
  def create_mailer_file
10
- template "mailer.rb", File.join('app/mailers', class_path, "#{file_name}.rb")
13
+ template "mailer.rb", File.join("app/mailers", class_path, "#{file_name}_mailer.rb")
14
+
15
+ in_root do
16
+ if behavior == :invoke && !File.exist?(application_mailer_file_name)
17
+ template "application_mailer.rb", application_mailer_file_name
18
+ end
19
+ end
11
20
  end
12
21
 
13
22
  hook_for :template_engine, :test_framework
23
+
24
+ private
25
+ def file_name # :doc:
26
+ @_file_name ||= super.sub(/_mailer\z/i, "")
27
+ end
28
+
29
+ def application_mailer_file_name
30
+ @_application_mailer_file_name ||= if mountable_engine?
31
+ "app/mailers/#{namespaced_path}/application_mailer.rb"
32
+ else
33
+ "app/mailers/application_mailer.rb"
34
+ end
35
+ end
14
36
  end
15
37
  end
16
38
  end
@@ -0,0 +1,6 @@
1
+ <% module_namespacing do -%>
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ <% end %>
@@ -1,17 +1,16 @@
1
1
  <% module_namespacing do -%>
2
- class <%= class_name %> < ActionMailer::Base
3
- default <%= key_value :from, '"from@example.com"' %>
2
+ class <%= class_name %>Mailer < ApplicationMailer
4
3
  <% actions.each do |action| -%>
5
4
 
6
5
  # Subject can be set in your I18n file at config/locales/en.yml
7
6
  # with the following lookup:
8
7
  #
9
- # en.<%= file_path.gsub("/",".") %>.<%= action %>.subject
8
+ # en.<%= file_path.tr("/",".") %>_mailer.<%= action %>.subject
10
9
  #
11
10
  def <%= action %>
12
11
  @greeting = "Hi"
13
12
 
14
- mail <%= key_value :to, '"to@example.org"' %>
13
+ mail to: "to@example.org"
15
14
  end
16
15
  <% end -%>
17
16
  end
metadata CHANGED
@@ -1,97 +1,166 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.9
5
- prerelease:
4
+ version: 6.1.7.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - David Heinemeier Hansson
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-12 00:00:00.000000000 Z
11
+ date: 2023-08-22 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.7.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.7.6
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: actionpack
16
29
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
30
  requirements:
19
31
  - - '='
20
32
  - !ruby/object:Gem::Version
21
- version: 3.2.9
33
+ version: 6.1.7.6
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 6.1.7.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: actionview
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 6.1.7.6
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 6.1.7.6
55
+ - !ruby/object:Gem::Dependency
56
+ name: activejob
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 6.1.7.6
22
62
  type: :runtime
23
63
  prerelease: false
24
64
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
65
  requirements:
27
66
  - - '='
28
67
  - !ruby/object:Gem::Version
29
- version: 3.2.9
68
+ version: 6.1.7.6
30
69
  - !ruby/object:Gem::Dependency
31
70
  name: mail
32
71
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
72
  requirements:
35
- - - ~>
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.5'
76
+ - - ">="
36
77
  - !ruby/object:Gem::Version
37
- version: 2.4.4
78
+ version: 2.5.4
38
79
  type: :runtime
39
80
  prerelease: false
40
81
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
82
  requirements:
43
- - - ~>
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '2.5'
86
+ - - ">="
44
87
  - !ruby/object:Gem::Version
45
- version: 2.4.4
46
- description: Email on Rails. Compose, deliver, receive, and test emails using the
47
- familiar controller/view pattern. First-class support for multipart email and attachments.
88
+ version: 2.5.4
89
+ - !ruby/object:Gem::Dependency
90
+ name: rails-dom-testing
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '2.0'
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2.0'
103
+ description: Email on Rails. Compose, deliver, and test emails using the familiar
104
+ controller/view pattern. First-class support for multipart email and attachments.
48
105
  email: david@loudthinking.com
49
106
  executables: []
50
107
  extensions: []
51
108
  extra_rdoc_files: []
52
109
  files:
53
110
  - CHANGELOG.md
54
- - README.rdoc
55
111
  - MIT-LICENSE
112
+ - README.rdoc
113
+ - lib/action_mailer.rb
56
114
  - lib/action_mailer/base.rb
57
115
  - lib/action_mailer/collector.rb
116
+ - lib/action_mailer/delivery_job.rb
58
117
  - lib/action_mailer/delivery_methods.rb
118
+ - lib/action_mailer/gem_version.rb
119
+ - lib/action_mailer/inline_preview_interceptor.rb
59
120
  - lib/action_mailer/log_subscriber.rb
121
+ - lib/action_mailer/mail_delivery_job.rb
60
122
  - lib/action_mailer/mail_helper.rb
123
+ - lib/action_mailer/mail_with_error_handling.rb
124
+ - lib/action_mailer/message_delivery.rb
125
+ - lib/action_mailer/parameterized.rb
126
+ - lib/action_mailer/preview.rb
61
127
  - lib/action_mailer/railtie.rb
128
+ - lib/action_mailer/rescuable.rb
62
129
  - lib/action_mailer/test_case.rb
63
130
  - lib/action_mailer/test_helper.rb
64
131
  - lib/action_mailer/version.rb
65
- - lib/action_mailer.rb
66
- - lib/rails/generators/mailer/mailer_generator.rb
67
- - lib/rails/generators/mailer/templates/mailer.rb
68
132
  - lib/rails/generators/mailer/USAGE
69
- homepage: http://www.rubyonrails.org
70
- licenses: []
71
- post_install_message:
133
+ - lib/rails/generators/mailer/mailer_generator.rb
134
+ - lib/rails/generators/mailer/templates/application_mailer.rb.tt
135
+ - lib/rails/generators/mailer/templates/mailer.rb.tt
136
+ homepage: https://rubyonrails.org
137
+ licenses:
138
+ - MIT
139
+ metadata:
140
+ bug_tracker_uri: https://github.com/rails/rails/issues
141
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.7.6/actionmailer/CHANGELOG.md
142
+ documentation_uri: https://api.rubyonrails.org/v6.1.7.6/
143
+ mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
144
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.7.6/actionmailer
145
+ rubygems_mfa_required: 'true'
146
+ post_install_message:
72
147
  rdoc_options: []
73
148
  require_paths:
74
149
  - lib
75
150
  required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
151
  requirements:
78
- - - ! '>='
152
+ - - ">="
79
153
  - !ruby/object:Gem::Version
80
- version: 1.8.7
154
+ version: 2.5.0
81
155
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
156
  requirements:
84
- - - ! '>='
157
+ - - ">="
85
158
  - !ruby/object:Gem::Version
86
159
  version: '0'
87
- segments:
88
- - 0
89
- hash: 125340086147061464
90
160
  requirements:
91
161
  - none
92
- rubyforge_project:
93
- rubygems_version: 1.8.24
94
- signing_key:
95
- specification_version: 3
96
- summary: Email composition, delivery, and receiving framework (part of Rails).
162
+ rubygems_version: 3.3.3
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Email composition and delivery framework (part of Rails).
97
166
  test_files: []