actionmailer 5.2.3

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.

@@ -0,0 +1,144 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_job"
4
+
5
+ module ActionMailer
6
+ # Provides helper methods for testing Action Mailer, including #assert_emails
7
+ # and #assert_no_emails.
8
+ module TestHelper
9
+ include ActiveJob::TestHelper
10
+
11
+ # Asserts that the number of emails sent matches the given number.
12
+ #
13
+ # def test_emails
14
+ # assert_emails 0
15
+ # ContactMailer.welcome.deliver_now
16
+ # assert_emails 1
17
+ # ContactMailer.welcome.deliver_now
18
+ # assert_emails 2
19
+ # end
20
+ #
21
+ # If a block is passed, that block should cause the specified number of
22
+ # emails to be sent.
23
+ #
24
+ # def test_emails_again
25
+ # assert_emails 1 do
26
+ # ContactMailer.welcome.deliver_now
27
+ # end
28
+ #
29
+ # assert_emails 2 do
30
+ # ContactMailer.welcome.deliver_now
31
+ # ContactMailer.welcome.deliver_now
32
+ # end
33
+ # end
34
+ def assert_emails(number)
35
+ if block_given?
36
+ original_count = ActionMailer::Base.deliveries.size
37
+ yield
38
+ new_count = ActionMailer::Base.deliveries.size
39
+ assert_equal number, new_count - original_count, "#{number} emails expected, but #{new_count - original_count} were sent"
40
+ else
41
+ assert_equal number, ActionMailer::Base.deliveries.size
42
+ end
43
+ end
44
+
45
+ # Asserts that no emails have been sent.
46
+ #
47
+ # def test_emails
48
+ # assert_no_emails
49
+ # ContactMailer.welcome.deliver_now
50
+ # assert_emails 1
51
+ # end
52
+ #
53
+ # If a block is passed, that block should not cause any emails to be sent.
54
+ #
55
+ # def test_emails_again
56
+ # assert_no_emails do
57
+ # # No emails should be sent from this block
58
+ # end
59
+ # end
60
+ #
61
+ # Note: This assertion is simply a shortcut for:
62
+ #
63
+ # assert_emails 0, &block
64
+ def assert_no_emails(&block)
65
+ assert_emails 0, &block
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: [ ActionMailer::DeliveryJob, ActionMailer::Parameterized::DeliveryJob ], &block
94
+ end
95
+
96
+ # Asserts that block should cause the specified email
97
+ # to be enqueued.
98
+ #
99
+ # def test_email_in_block
100
+ # assert_enqueued_email_with ContactMailer, :welcome do
101
+ # ContactMailer.welcome.deliver_later
102
+ # end
103
+ # end
104
+ #
105
+ # If +args+ is provided as a Hash, a parameterized email is matched.
106
+ #
107
+ # def test_parameterized_email
108
+ # assert_enqueued_email_with ContactMailer, :welcome,
109
+ # args: {email: 'user@example.com} do
110
+ # ContactMailer.with(email: 'user@example.com').welcome.deliver_later
111
+ # end
112
+ # end
113
+ def assert_enqueued_email_with(mailer, method, args: nil, queue: "mailers", &block)
114
+ if args.is_a? Hash
115
+ job = ActionMailer::Parameterized::DeliveryJob
116
+ args = [mailer.to_s, method.to_s, "deliver_now", args]
117
+ else
118
+ job = ActionMailer::DeliveryJob
119
+ args = [mailer.to_s, method.to_s, "deliver_now", *args]
120
+ end
121
+
122
+ assert_enqueued_with(job: job, args: args, queue: queue, &block)
123
+ end
124
+
125
+ # Asserts that no emails are enqueued for later delivery.
126
+ #
127
+ # def test_no_emails
128
+ # assert_no_enqueued_emails
129
+ # ContactMailer.welcome.deliver_later
130
+ # assert_enqueued_emails 1
131
+ # end
132
+ #
133
+ # If a block is provided, it should not cause any emails to be enqueued.
134
+ #
135
+ # def test_no_emails
136
+ # assert_no_enqueued_emails do
137
+ # # No emails should be enqueued from this block
138
+ # end
139
+ # end
140
+ def assert_no_enqueued_emails(&block)
141
+ assert_no_enqueued_jobs only: [ ActionMailer::DeliveryJob, ActionMailer::Parameterized::DeliveryJob ], &block
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "gem_version"
4
+
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
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ Description:
2
+ ============
3
+ Stubs out a new mailer and its views. Passes the mailer name, either
4
+ CamelCased or under_scored, and an optional list of emails as arguments.
5
+
6
+ This generates a mailer class in app/mailers and invokes your template
7
+ engine and test framework generators.
8
+
9
+ Example:
10
+ ========
11
+ rails generate mailer Notifications signup forgot_password invoice
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
17
+
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails
4
+ module Generators
5
+ class MailerGenerator < NamedBase
6
+ source_root File.expand_path("templates", __dir__)
7
+
8
+ argument :actions, type: :array, default: [], banner: "method method"
9
+
10
+ check_class_collision suffix: "Mailer"
11
+
12
+ def create_mailer_file
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
20
+ end
21
+
22
+ hook_for :template_engine, :test_framework
23
+
24
+ private
25
+ def file_name # :doc:
26
+ @_file_name ||= super.gsub(/_mailer/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
36
+ end
37
+ end
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 %>
@@ -0,0 +1,17 @@
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %>Mailer < ApplicationMailer
3
+ <% actions.each do |action| -%>
4
+
5
+ # Subject can be set in your I18n file at config/locales/en.yml
6
+ # with the following lookup:
7
+ #
8
+ # en.<%= file_path.tr("/",".") %>_mailer.<%= action %>.subject
9
+ #
10
+ def <%= action %>
11
+ @greeting = "Hi"
12
+
13
+ mail to: "to@example.org"
14
+ end
15
+ <% end -%>
16
+ end
17
+ <% end -%>
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: actionmailer
3
+ version: !ruby/object:Gem::Version
4
+ version: 5.2.3
5
+ platform: ruby
6
+ authors:
7
+ - David Heinemeier Hansson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionview
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 5.2.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 5.2.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: activejob
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 5.2.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 5.2.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: mail
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.5'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.5.4
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '2.5'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.5.4
75
+ - !ruby/object:Gem::Dependency
76
+ name: rails-dom-testing
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '2.0'
89
+ description: Email on Rails. Compose, deliver, receive, and test emails using the
90
+ familiar controller/view pattern. First-class support for multipart email and attachments.
91
+ email: david@loudthinking.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - CHANGELOG.md
97
+ - MIT-LICENSE
98
+ - README.rdoc
99
+ - lib/action_mailer.rb
100
+ - lib/action_mailer/base.rb
101
+ - lib/action_mailer/collector.rb
102
+ - lib/action_mailer/delivery_job.rb
103
+ - lib/action_mailer/delivery_methods.rb
104
+ - lib/action_mailer/gem_version.rb
105
+ - lib/action_mailer/inline_preview_interceptor.rb
106
+ - lib/action_mailer/log_subscriber.rb
107
+ - lib/action_mailer/mail_helper.rb
108
+ - lib/action_mailer/message_delivery.rb
109
+ - lib/action_mailer/parameterized.rb
110
+ - lib/action_mailer/preview.rb
111
+ - lib/action_mailer/railtie.rb
112
+ - lib/action_mailer/rescuable.rb
113
+ - lib/action_mailer/test_case.rb
114
+ - lib/action_mailer/test_helper.rb
115
+ - lib/action_mailer/version.rb
116
+ - lib/rails/generators/mailer/USAGE
117
+ - lib/rails/generators/mailer/mailer_generator.rb
118
+ - lib/rails/generators/mailer/templates/application_mailer.rb.tt
119
+ - lib/rails/generators/mailer/templates/mailer.rb.tt
120
+ homepage: http://rubyonrails.org
121
+ licenses:
122
+ - MIT
123
+ metadata:
124
+ source_code_uri: https://github.com/rails/rails/tree/v5.2.3/actionmailer
125
+ changelog_uri: https://github.com/rails/rails/blob/v5.2.3/actionmailer/CHANGELOG.md
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 2.2.2
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements:
141
+ - none
142
+ rubygems_version: 3.0.1
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Email composition, delivery, and receiving framework (part of Rails).
146
+ test_files: []