Commit Graph

1512 Commits

Author SHA1 Message Date
yuuji.yaginuma
2f469dc308 Clear mail after test
If clear it before the test, the mail of the last executed test will not
be correctly cleared.

Therefore, executing the test with seed below will result in an error.

```
./bin/test -w --seed 55480
Run options: --seed 55480

# Running:

...........................................................................................................................................................F

Failure:
MailDeliveryTest#test_does_not_increment_the_deliveries_collection_on_error [/home/yaginuma/program/rails/master_y_yagi/rails/actionmailer/test/delivery_methods_test.rb:221]:
--- expected
+++ actual
@@ -1 +1 @@
-[]
+[#<Mail::Message:47011389364640, Multipart: false, Headers: <Date: Mon, 14 Aug 2017 07:48:40 +0900>, <From: test-sender@test.com>, <To: test-receiver@test.com>, <Message-ID: <5990d748ea5b2_29342ac1af8bcf40886f7@yaginuma.mail>>, <Subject: Test Subject>, <Mime-Version: 1.0>, <Content-Type: text/plain>, <Content-Transfer-Encoding: 7bit>>]

bin/test test/delivery_methods_test.rb:216
```
2017-08-14 07:49:13 +09:00
Rafael França
b9e0b4f199 Merge pull request #29559 from kirs/eager-load-controller-actions
Eager load controller actions to reduce response time of the first request
2017-08-11 17:54:04 -04:00
Youssef Boulkaid
d33bdef821 Remove outdated comment [ci skip]
The comment was describing a previous version of the method with
a different signature. This is outdated since e76c38e
2017-08-06 04:20:16 +02:00
Rafael Mendonça França
feb1ddae02 Merge remote-tracking branch 'origin/master' into unlock-minitest 2017-08-01 17:34:14 -04:00
Kir Shatrov
0668c22a41 Eager load controller and mailer actions
On the first request, ActionController::Base#action_methods computes
and memoized the list of available actions [1]. With this PR we move
this expensive operation into eager load step to reduce response time
of the first request served in production.

This also reduces the memory footprint when running on forking server
like Unicorn.

[1] a3813dce9a/actionpack/lib/abstract_controller/base.rb (L66-L77)
2017-07-29 14:03:52 +03:00
Kir Shatrov
82df8c2ca5 Use frozen string literal in actionmailer/ 2017-07-23 18:17:19 +03:00
Kasper Timm Hansen
aad42dce10 Merge branch 'master' into unlock-minitest 2017-07-15 21:17:27 +02:00
Xavier Noria
92c29d82eb Merge branch 'master' into require_relative_2017 2017-07-02 13:50:25 -07:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Matthew Draper
3420a14590 Merge pull request #29540 from kirs/rubocop-frozen-string
Enforce frozen string in Rubocop
2017-07-02 01:11:50 +09:30
Matthew Draper
afb66a5a59 Merge pull request #29506 from pat/frozen-string-literals
Make ActiveSupport frozen-string-literal friendly.
2017-07-02 01:07:12 +09:30
Akira Matsuda
cd9cc721ab [Action Mailer] require => require_relative 2017-07-01 18:38:05 +09:00
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Grey Baker
3e6ce1cd69 Add source code and changelog links to gemspecs 2017-06-28 10:06:01 +01:00
Pat Allan
dd491b24ff Make ActionMailer frozen string literal friendly. 2017-06-20 19:45:46 +10:00
Ryuta Kamizono
6bb7d50dec Fix formatting of ActionMailer::MessageDelivery doc [ci skip] 2017-06-16 10:33:53 +09:00
Matthew Mongeau
425e351a5e Document setting the delivery_job for ActionMailer [ci skip] 2017-06-16 10:13:40 +09:00
Ryuta Kamizono
6e227ad345 Fix indentation [ci skip] 2017-06-15 21:44:19 +09:00
Matthew Mongeau
d9bbde09fc Allow mailers to configure their delivery job
Setting delivery_job on a mailer class will cause MessageDelivery to use
the specified job instead of ActionMailer::DeliveryJob:

    class MyMailer < ApplicationMailer
      self.delivery_job = MyCustomDeliveryJob

      ...
    end
2017-06-15 16:41:23 +09:00
bogdanvlviv
6673cf7071
Use require_relative instead of require with full path 2017-06-14 12:10:17 +03:00
Genadi Samokovarov
b6b0c99ff3 Use mattr_accessor default: option throughout the project 2017-06-03 13:52:48 +03:00
Kasper Timm Hansen
e1758b5e8c Merge branch 'master' into unlock-minitest 2017-05-29 20:37:35 +02:00
David Heinemeier Hansson
1c275d812f Add option for class_attribute default (#29270)
* Allow a default value to be declared for class_attribute

* Convert to using class_attribute default rather than explicit setter

* Removed instance_accessor option by mistake

* False is a valid default value

* Documentation
2017-05-29 18:01:50 +02:00
bogdanvlviv
40bdbce191
Define path with __dir__
".. with __dir__ we can restore order in the Universe." - by @fxn

Related to 5b8738c2df003a96f0e490c43559747618d10f5f
2017-05-23 00:53:51 +03:00
David Heinemeier Hansson
75fa8dd309 Use recyclable cache keys (#29092) 2017-05-18 18:12:32 +02:00
Ryuta Kamizono
b201474756 Should escape meta characters in regexp 2017-05-07 04:10:00 +09:00
Rafael França
a23846e0ab Merge pull request #28835 from fphilipe/master
Add missing require in ActionMailer::Base
2017-05-02 11:16:53 -07:00
Philipe Fatio
eddbb62f94
Add missing require in ActionMailer
Without this, Action Mailer doesn't work like it used to on version 4.
The following snippet fails since version 5:

    > require 'action_mailer'
    > ActionMailer::Base
    NameError: uninitialized constant ActiveSupport::Rescuable
2017-05-02 07:22:48 +02:00
Rafael Mendonça França
0d35a60ff7
Avoid stubing on this test
This will avoid to the test fail when running in isolation because the
message generated is nil.
2017-04-27 02:05:00 -07:00
Rafael França
f680664d4e Merge pull request #28244 from ixti/improve/action-mailer-preview-params
Pass request params to ActionMailer::Preview
2017-04-26 20:15:30 -07:00
yuuji.yaginuma
e4cf71bf7a Remove duplicated delivery_method definition
`ActionMailer::Base.delivery_method` is already defined in
https://github.com/rails/rails/blob/master/actionmailer/test/parameterized_test.rb#L13
2017-04-07 21:58:08 +09:00
Matthew Draper
6c08d480f1 Start Rails 5.2 development 2017-03-22 10:11:39 +10:30
Andrew White
c7135d2c8e Use better duration aliases in tests 2017-03-15 14:56:27 +00:00
Andrew White
ef28b68496 Don't cast to float unnecessarily
Adding durations to `Time` instances is perfectly okay.
2017-03-15 08:19:27 +00:00
Krzysztof Zych
3a6e84715e Document using default_url_options in an ActionMailer class. 2017-03-08 13:34:28 +01:00
Andrew White
75924c4517 Deprecate implicit coercion of ActiveSupport::Duration
Currently `ActiveSupport::Duration` implicitly converts to a seconds
value when used in a calculation except for the explicit examples of
addition and subtraction where the duration is the receiver, e.g:

    >> 2 * 1.day
    => 172800

This results in lots of confusion especially when using durations
with dates because adding/subtracting a value from a date treats
integers as a day and not a second, e.g:

    >> Date.today
    => Wed, 01 Mar 2017
    >> Date.today + 2 * 1.day
    => Mon, 10 Apr 2490

To fix this we're implementing `coerce` so that we can provide a
deprecation warning with the intent of removing the implicit coercion
in Rails 5.2, e.g:

    >> 2 * 1.day
    DEPRECATION WARNING: Implicit coercion of ActiveSupport::Duration
    to a Numeric is deprecated and will raise a TypeError in Rails 5.2.
    => 172800

In Rails 5.2 it will raise `TypeError`, e.g:

    >> 2 * 1.day
    TypeError: ActiveSupport::Duration can't be coerced into Integer

This is the same behavior as with other types in Ruby, e.g:

    >> 2 * "foo"
    TypeError: String can't be coerced into Integer
    >> "foo" * 2
    => "foofoo"

As part of this deprecation add `*` and `/` methods to `AS::Duration`
so that calculations that keep the duration as the receiver work
correctly whether the final receiver is a `Date` or `Time`, e.g:

    >> Date.today
    => Wed, 01 Mar 2017
    >> Date.today + 1.day * 2
    => Fri, 03 Mar 2017

Fixes #27457.
2017-03-02 08:00:22 +00:00
Alexey Zapparov
8e6c6d854c
Pass request params to ActionMailer::Preview 2017-03-01 20:54:14 +01:00
Rafael Mendonça França
f4acdd83ff
Preparing for 5.1.0.beta1 release 2017-02-23 14:53:21 -05:00
Jon Moss
f4d2bcdd6d Add backticks around constant
[ci skip]
2017-02-21 11:45:50 -05:00
Stan Lo
dde7134e07 Freeze fragment cache related instrument name.
ActionMailer::Base#instrument_name and
ActionController::Base#instrument_name will be frequently called once
caching is enabled. So it's better to freeze them instead of create new
string on every call.

Also, the instrument name in #instrument_fragment_cache will usually
be "write_fragment.action_controller" or
"read_fragment.action_controller". So freezing them might also gain some
performance improvement. We have done something like this in other places:
https://github.com/rails/rails/blob/master/actionview/lib/action_view/template.rb#L348
2017-02-07 00:41:02 +08:00
yuuji.yaginuma
53b98f1dda Add :args to process.action_mailer event 2017-02-04 11:43:24 +09:00
Eugene Kenny
ebededb372
Don't mutate raw_source in mailer preview interceptor
The raw_source method is documented as returning the exact value that
was used to create the body; mutating it breaks that contract.

Additionally, if the value used to create the body is blank, raw_source
returns a frozen string which causes the interceptor to raise an error.
2017-01-30 22:20:47 -07:00
yuuji.yaginuma
18cc66cef6 add default value to deliver_later_queue_name option [ci skip] 2017-01-31 10:23:21 +09:00
Rafael Mendonça França
2dadf73891
Document with with an example an link to Parameterized
Also change the class_methods to ClassMethods since the former document
the method as an instance method of Parameterized not as a class method.
2017-01-30 13:38:12 -05:00
Rafael Mendonça França
d3cb00b87e
✂️ 2017-01-30 13:38:06 -05:00
Rafael Mendonça França
bfda627713
No need to advertise in the rdoc documentation 2017-01-30 13:31:11 -05:00
Rafael Mendonça França
0435d65000
Avoid should in test names 2017-01-30 13:28:31 -05:00
Rafael Mendonça França
735aa635c5
Implement respond_to_missing? in the Parameterized::Mailer class 2017-01-30 13:28:14 -05:00
Rafael Mendonça França
bfc69e873d
Remove unneeded nodoc 2017-01-30 13:17:52 -05:00
Rafael Mendonça França
58f9c4f096
Override the initializers instead of using tap
We own the class so we can override the initialize.
2017-01-30 13:02:30 -05:00