actionmailer 4.2.11.3 → 6.0.0

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,7 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_job"
4
+
1
5
  module ActionMailer
2
6
  # Provides helper methods for testing Action Mailer, including #assert_emails
3
- # and #assert_no_emails
7
+ # and #assert_no_emails.
4
8
  module TestHelper
9
+ include ActiveJob::TestHelper
10
+
5
11
  # Asserts that the number of emails sent matches the given number.
6
12
  #
7
13
  # def test_emails
@@ -22,13 +28,13 @@ module ActionMailer
22
28
  #
23
29
  # assert_emails 2 do
24
30
  # ContactMailer.welcome.deliver_now
25
- # ContactMailer.welcome.deliver_now
31
+ # ContactMailer.welcome.deliver_later
26
32
  # end
27
33
  # end
28
- def assert_emails(number)
34
+ def assert_emails(number, &block)
29
35
  if block_given?
30
36
  original_count = ActionMailer::Base.deliveries.size
31
- yield
37
+ perform_enqueued_jobs(only: ->(job) { delivery_job_filter(job) }, &block)
32
38
  new_count = ActionMailer::Base.deliveries.size
33
39
  assert_equal number, new_count - original_count, "#{number} emails expected, but #{new_count - original_count} were sent"
34
40
  else
@@ -36,7 +42,7 @@ module ActionMailer
36
42
  end
37
43
  end
38
44
 
39
- # Assert that no emails have been sent.
45
+ # Asserts that no emails have been sent.
40
46
  #
41
47
  # def test_emails
42
48
  # assert_no_emails
@@ -54,9 +60,103 @@ module ActionMailer
54
60
  #
55
61
  # Note: This assertion is simply a shortcut for:
56
62
  #
57
- # assert_emails 0
63
+ # assert_emails 0, &block
58
64
  def assert_no_emails(&block)
59
65
  assert_emails 0, &block
60
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: "mailers", &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, &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
+
156
+ def delivery_job_filter(job)
157
+ job_class = job.is_a?(Hash) ? job.fetch(:job) : job.class
158
+
159
+ Base.descendants.map(&:delivery_job).include?(job_class)
160
+ end
61
161
  end
62
162
  end
@@ -1,4 +1,6 @@
1
- require_relative 'gem_version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "gem_version"
2
4
 
3
5
  module ActionMailer
4
6
  # Returns the version of the currently loaded Action Mailer as a
@@ -11,7 +11,7 @@ Example:
11
11
  rails generate mailer Notifications signup forgot_password invoice
12
12
 
13
13
  creates a Notifications mailer class, views, and test:
14
- Mailer: app/mailers/notifications.rb
15
- Views: app/views/notifications/signup.text.erb [...]
16
- Test: test/mailers/notifications_test.rb
14
+ Mailer: app/mailers/notifications_mailer.rb
15
+ Views: app/views/notifications_mailer/signup.text.erb [...]
16
+ Test: test/mailers/notifications_mailer_test.rb
17
17
 
@@ -1,19 +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__)
5
7
 
6
8
  argument :actions, type: :array, default: [], banner: "method method"
7
- check_class_collision
9
+
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")
11
- if self.behavior == :invoke
12
- template "application_mailer.rb", 'app/mailers/application_mailer.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
13
19
  end
14
20
  end
15
21
 
16
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
17
36
  end
18
37
  end
19
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,11 +1,11 @@
1
1
  <% module_namespacing do -%>
2
- class <%= class_name %> < ApplicationMailer
2
+ class <%= class_name %>Mailer < ApplicationMailer
3
3
  <% actions.each do |action| -%>
4
4
 
5
5
  # Subject can be set in your I18n file at config/locales/en.yml
6
6
  # with the following lookup:
7
7
  #
8
- # en.<%= file_path.tr("/",".") %>.<%= action %>.subject
8
+ # en.<%= file_path.tr("/",".") %>_mailer.<%= action %>.subject
9
9
  #
10
10
  def <%= action %>
11
11
  @greeting = "Hi"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.11.3
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2019-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.11.3
19
+ version: 6.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.2.11.3
26
+ version: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionview
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.11.3
33
+ version: 6.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.11.3
40
+ version: 6.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activejob
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 4.2.11.3
47
+ version: 6.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 4.2.11.3
54
+ version: 6.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mail
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -78,22 +78,16 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '1.0'
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: 1.0.5
81
+ version: '2.0'
85
82
  type: :runtime
86
83
  prerelease: false
87
84
  version_requirements: !ruby/object:Gem::Requirement
88
85
  requirements:
89
86
  - - "~>"
90
87
  - !ruby/object:Gem::Version
91
- version: '1.0'
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: 1.0.5
95
- description: Email on Rails. Compose, deliver, receive, and test emails using the
96
- familiar controller/view pattern. First-class support for multipart email and attachments.
88
+ version: '2.0'
89
+ description: Email on Rails. Compose, deliver, and test emails using the familiar
90
+ controller/view pattern. First-class support for multipart email and attachments.
97
91
  email: david@loudthinking.com
98
92
  executables: []
99
93
  extensions: []
@@ -110,21 +104,26 @@ files:
110
104
  - lib/action_mailer/gem_version.rb
111
105
  - lib/action_mailer/inline_preview_interceptor.rb
112
106
  - lib/action_mailer/log_subscriber.rb
107
+ - lib/action_mailer/mail_delivery_job.rb
113
108
  - lib/action_mailer/mail_helper.rb
114
109
  - lib/action_mailer/message_delivery.rb
110
+ - lib/action_mailer/parameterized.rb
115
111
  - lib/action_mailer/preview.rb
116
112
  - lib/action_mailer/railtie.rb
113
+ - lib/action_mailer/rescuable.rb
117
114
  - lib/action_mailer/test_case.rb
118
115
  - lib/action_mailer/test_helper.rb
119
116
  - lib/action_mailer/version.rb
120
117
  - lib/rails/generators/mailer/USAGE
121
118
  - lib/rails/generators/mailer/mailer_generator.rb
122
- - lib/rails/generators/mailer/templates/application_mailer.rb
123
- - lib/rails/generators/mailer/templates/mailer.rb
124
- homepage: http://www.rubyonrails.org
119
+ - lib/rails/generators/mailer/templates/application_mailer.rb.tt
120
+ - lib/rails/generators/mailer/templates/mailer.rb.tt
121
+ homepage: https://rubyonrails.org
125
122
  licenses:
126
123
  - MIT
127
- metadata: {}
124
+ metadata:
125
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.0/actionmailer
126
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.0/actionmailer/CHANGELOG.md
128
127
  post_install_message:
129
128
  rdoc_options: []
130
129
  require_paths:
@@ -133,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
132
  requirements:
134
133
  - - ">="
135
134
  - !ruby/object:Gem::Version
136
- version: 1.9.3
135
+ version: 2.5.0
137
136
  required_rubygems_version: !ruby/object:Gem::Requirement
138
137
  requirements:
139
138
  - - ">="
@@ -141,8 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
140
  version: '0'
142
141
  requirements:
143
142
  - none
144
- rubygems_version: 3.0.3
143
+ rubygems_version: 3.0.1
145
144
  signing_key:
146
145
  specification_version: 4
147
- summary: Email composition, delivery, and receiving framework (part of Rails).
146
+ summary: Email composition and delivery framework (part of Rails).
148
147
  test_files: []
@@ -1,4 +0,0 @@
1
- class ApplicationMailer < ActionMailer::Base
2
- default from: "from@example.com"
3
- layout 'mailer'
4
- end