Commit Graph

1189 Commits

Author SHA1 Message Date
Cristian Bica
9e7f4a94ca Updated rdoc / guides / release notes related to ActiveJob / ActionMailer 2014-08-20 17:48:34 +03:00
Cristian Bica
f4ee114746 Deprecated .deliver / .deliver! to .deliver_now / .deliver_now! 2014-08-20 17:48:34 +03:00
Akira Matsuda
0df2a83b7f Clear deliveries in order not to affect other tests 2014-08-20 19:07:03 +09:00
Lucas Mazza
63f7b22a4e Remove global helpers from the ActionMailer test suite. 2014-08-19 23:53:19 -03:00
David Heinemeier Hansson
78728af2c9 Extra space 2014-08-19 19:31:18 -07:00
Lucas Mazza
04db4c2868 Add set_delivery_method and restore_delivery_method to ActionMailer::TestCase.
This way these methods are available outside the ActionMailer test suite, but
they are still duplicated inside `test/abstract_unit` for test cases that don't
inherit from the `ActionMailer::TestCase` class.
2014-08-19 23:26:45 -03:00
Rafael Mendonça França
fad9e729f1 Fix the rails-dom-testing dependecy 2014-08-19 16:41:38 -03:00
Rafael Mendonça França
c78da4d5c4 Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
2014-08-17 22:38:22 -03:00
David Heinemeier Hansson
6e6ebeb03c Add CHANGELOG entry for #deliver_later 2014-08-17 16:57:57 -07:00
Abdelkader Boudih
2f7b239fca [ActiveJob] Use globalid gem 2014-08-17 23:10:45 +00:00
Abdelkader Boudih
299d1f2626 [ActionMailer] Rename ActionMailer::DelayedDeliveryJob to ActionMailer::DeliveryJob 2014-08-17 23:10:08 +00:00
Abdelkader Boudih
6a2ca149fd [ActiveJob] Fix test syntax 2014-08-17 23:09:42 +00:00
Cristian Bica
0e4e496a57 Fixed indentation 2014-08-16 00:30:20 +03:00
Cristian Bica
e034ac33ea Removed method missing from ActionMailer::MessageDelivery 2014-08-15 23:20:55 +03:00
Abdelkader Boudih
18303f6e82 Refactor DeliverLater into MessageDelivery 2014-08-14 11:05:35 +00:00
Abdelkader Boudih
b937ea893e Make ActionMailer::Previews methods class methods. 2014-08-14 10:55:12 +00:00
Cristian Bica
06908e60be Merge branch 'master' into activejob 2014-08-13 22:55:32 +03:00
Yves Senn
e9ce987a9a use :test delivery method for base_test.rb
This solves errors like:

```
BaseTest#test_you_can_register_multiple_observers_to_the_mail_object_that_both_get_informed_on_email_delivery:
Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 25
    /Users/senny/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `initialize'
    /Users/senny/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `open'
    /Users/senny/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/smtp.rb:541:in `tcp_socket'
    /Users/senny/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/smtp.rb:551:in `block in do_start'
    /Users/senny/.rbenv/versions/2.1.2/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
    /Users/senny/.rbenv/versions/2.1.2/lib/ruby/2.1.0/timeout.rb:101:in `call'
    /Users/senny/.rbenv/versions/2.1.2/lib/ruby/2.1.0/timeout.rb:101:in `timeout'
    /Users/senny/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/smtp.rb:550:in `do_start'
    /Users/senny/.rbenv/versions/2.1.2/lib/ruby/2.1.0/net/smtp.rb:520:in `start'
    /Users/senny/Projects/rails/.bundle/gems/mail-2.6.1/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
    /Users/senny/Projects/rails/.bundle/gems/mail-2.6.1/lib/mail/message.rb:2136:in `do_delivery'
    /Users/senny/Projects/rails/.bundle/gems/mail-2.6.1/lib/mail/message.rb:232:in `block in deliver'
    /Users/senny/Projects/rails/actionmailer/lib/action_mailer/base.rb:528:in `block in deliver_mail'
    /Users/senny/Projects/rails/activesupport/lib/active_support/notifications.rb:164:in `block in instrument'
    /Users/senny/Projects/rails/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    /Users/senny/Projects/rails/activesupport/lib/active_support/notifications.rb:164:in `instrument'
    /Users/senny/Projects/rails/actionmailer/lib/action_mailer/base.rb:526:in `deliver_mail'
    /Users/senny/Projects/rails/.bundle/gems/mail-2.6.1/lib/mail/message.rb:232:in `deliver'
    /Users/senny/Projects/rails/actionmailer/test/base_test.rb:598:in `block (2 levels) in <class:BaseTest>'
    /Users/senny/Projects/rails/actionmailer/test/base_test.rb:801:in `mail_side_effects'
    /Users/senny/Projects/rails/actionmailer/test/base_test.rb:593:in `block in <class:BaseTest>'
```
where the `:smtp` delivery method was leaked over to other test cases.
2014-08-13 16:00:19 +02:00
Akira Matsuda
2ef0d3bea6 actionmailer_tests_are_order_dependent! 2014-08-13 22:30:23 +09:00
Akira Matsuda
bc116a55ca AM, AP, AV, and AMo tests are already order_independent! 2014-08-13 21:25:10 +09:00
Abdelkader Boudih
67f8b6b2bc Added ActionMailer::DeliverLater 2014-08-13 11:36:32 +00:00
Rafael Mendonça França
a2400308ea Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
	actionpack/test/controller/integration_test.rb
	actionview/CHANGELOG.md
2014-08-12 11:10:42 -03:00
Rafael Mendonça França
e81f3c210e Nobody sucks so nobody should call this awful method name 2014-08-12 10:51:41 -03:00
Akira Matsuda
6ffb29d24e users_dont_suck_but_only_we_suck_and_only_our_tests_are_order_dependent!
Calling ActiveSupport::TestCase.i_suck_and_my_tests_are_order_dependent! in AS::TestCase makes
everyone's tests order dependent, which should never be done by the framework.
2014-08-12 19:37:04 +09:00
@schneems and @sgrif
2bbcca004c Deprecate *_path methods in mailers
Email does not support relative links since there is no implicit host. Therefore all links inside of emails must be fully qualified URLs. All path helpers are now deprecated. When removed, the error will give early indication to developers to use `*_url` methods instead.

Currently if a developer uses a `*_path` helper, their tests and `mail_view` will not catch the mistake. The only way to see the error is by sending emails in production. Preventing sending out emails with non-working path's is the desired end goal of this PR.

Currently path helpers are mixed-in to controllers (the ActionMailer::Base acts as a controller). All `*_url` and `*_path` helpers are made available through the same module. This PR separates this behavior into two modules so we can extend the `*_path` methods to add a Deprecation to them. Once deprecated we can use this same area to raise a NoMethodError and add an informative message directing the developer to use `*_url` instead.

The module with warnings is only mixed in when a controller returns false from the newly added `supports_relative_path?`.

Paired @sgrif & @schneems
2014-07-30 12:01:45 -05:00
Yves Senn
b8120ab14d Raise an exception when attachments are added after mail was called.
Closes #16163

Adding attachments after a call to `mail` will result in invalid emails.
This is related to the fact, that `mail` is making the required preparations
before the email is ready to be sent. These change depending on your
added attachments.
2014-07-29 09:24:06 +02:00
Rafael Mendonça França
08754f12e6 Merge branch 'rm-remove-mocha'
Conflicts:
	actionpack/test/abstract_unit.rb
2014-07-19 18:17:13 -03:00
Rafael Mendonça França
fd6aaaa0c3 Stop requiring mocha automatically
We are planning to remove mocha from our test suite because of
performance problems. To make this possible we should stop require mocha
on ActionSupport::TestCase.

This should not affect applications since users still need to add mocha
to Gemfile and this already load mocha.

Added FIXME notes to place that still need mocha removal
2014-07-19 17:35:12 -03:00
Guo Xiang Tan
ee35b79d4c Prefer to pass block when logging.
The Logger by default includes a guard which checks for the
logging level. By removing the custom logging guards, we can decouple
the logging guard from the logging action to be done.

This also follows the good practice listed on http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance.
2014-07-18 15:04:43 +08:00
Rafael Mendonça França
a8c667e8f1 Defining the right dependencies 2014-07-15 13:40:22 -03:00
Rafael Mendonça França
126a15e0fe Include the selector assertions on the test case
We don't need to require users to include this module on
ActionMailer::TestCase
2014-07-15 13:40:18 -03:00
Rafael Mendonça França
75fe384c81 Rails is a module not a class 2014-07-15 13:02:22 -03:00
Santosh Wadghule
dfee0327b5 Fix typos like a html to an html and 'an mail' to 'an email'. [ci skip] 2014-07-14 00:14:47 +05:30
Rafael Mendonça França
3229eda00c Merge pull request #11218 from kaspth/loofah-integration
Loofah-integration

Conflicts:
	actionpack/CHANGELOG.md
	actionview/CHANGELOG.md
2014-07-10 16:52:00 -03:00
Aaron Patterson
e0c6b35dac test i18n against a routed app 2014-07-07 15:08:12 -07:00
Dmitry Polushkin
99f8d4feeb add test coverage for the action mailer 2014-07-04 15:55:33 +01:00
Rafael Mendonça França
72f58b0244 Rename preview_enabled option to show_previews 2014-07-01 13:09:24 -03:00
Leonard Garvey
84ed7b8dfe Add configuration to enable mail previews
Adds `config.action_mailer.preview_enabled`

This allows mail previewing to be enabled easily in non-development
environments such as staging. The default is set to true for development
so no changes should be required to existing Rails applications.

The mail preview path can still be configured using the existing
`config.action_mailer.preview_path` configuration option.

Adding this avoids devs from having to do stuff like:
https://gist.github.com/lengarvey/fa2c9bd6cdbeba96526a

Update actionmailer/CHANGELOG with new configuration.
Update configuring guide with new configuratation.
Add `config.action_mailer.preview_path` to configuring guide.
2014-07-01 14:39:59 +10:00
Rafael Mendonça França
6a682e3f8b Merge pull request #15815 from DNNX/mail-helper-refactoring
Remove unused block parameter from #gsub call in AM::MailHelper#block_format
2014-06-19 13:27:03 -03:00
Viktar Basharymau
9f6a796234 Add logger.debug? guard to ActionMailer::LogSubscriber#process
*TLDR*: The method is 4 times faster when log level is higher than DEBUG.
Also, the other two methods, `#deliver` and `#receive` have similar guard statements,
so this commit adds some symmetry to the code.

This is probably not the most critical part of ActionMailer in terms
of performance, but here are some benchmarks:

```
require 'benchmark/ips'
require 'action_mailer'

event = ActiveSupport::Notifications::Event.new(
            'process.action_mailer',
            Time.now,
            Time.now,
            'bf4e2b36ce085fd35b24',
            { mailer: "UserMailer", action: :welcome }
        )

ActionMailer::Base.logger = ActiveSupport::Logger.new '/dev/null'

subscriber = ActionMailer::LogSubscriber.new
def subscriber.process_with_guard(event)
  return unless logger.debug?
  mailer = event.payload[:mailer]
  action = event.payload[:action]
  debug("\n#{mailer}##{action}: processed outbound mail in #{event.duration.round(1)}ms")
end

Benchmark.ips do |r|
  ActionMailer::Base.logger.level = ::Logger::Severity::INFO
  r.report('no guard') { subscriber.process(event) }
  r.report('   guard') { subscriber.process_with_guard(event) }
end

__END__
Calculating -------------------------------------
            no guard      9640 i/100ms
               guard     38381 i/100ms
-------------------------------------------------
            no guard   169166.9 (±10.2%) i/s -     838680 in   5.007262s
               guard   728184.9 (±9.6%) i/s -    3607814 in   4.999218s
```

When log level is DEBUG, the _guarded_ method is a bit slower. This is a
good tradeoff for 4x improvement in production mode.

```
Benchmark.ips do |r|
  ActionMailer::Base.logger.level = ::Logger::Severity::DEBUG
  r.report('no guard') { subscriber.process(event) }
  r.report('   guard') { subscriber.process_with_guard(event) }
end

__END__
Calculating -------------------------------------
            no guard      4970 i/100ms
               guard      4564 i/100ms
-------------------------------------------------
            no guard    55617.4 (±3.5%) i/s -     278320 in   5.010523s
               guard    49452.1 (±5.6%) i/s -     251020 in   5.093358s

```
2014-06-19 18:52:11 +03:00
Viktar Basharymau
e60c85b4b6 Remove unused block parameter from #gsub call in AM::MailHelper#block_format 2014-06-19 17:40:37 +03:00
Timm
ff1b7e7535 Restore delivery method on teardowns. 2014-06-16 21:04:26 +02:00
Timm
9c9875b059 Inline Assertion reference. 2014-06-16 21:04:26 +02:00
Timm
b276108330 Remove response faking. 2014-06-16 21:04:26 +02:00
Timm
1a8ca9fc35 Use 1.9 syntax. 2014-06-16 21:04:25 +02:00
Timm
94ca27b190 Added rails-dom-testing and rails-html-sanitizer to Gemfile. Added tests for assert_select_email. 2014-06-16 21:04:17 +02:00
Yves Senn
f59ed560ac allow preview interceptors to be registered through config.action_mailer.
This was partially broken because `preview_interceptors=` just assigned the
raw values, whithout going through `register_preview_interceptor`. Now the
Action Mailer railtie takes care of the `preview_interceptors` option.

This commit is a partial revert of:

Revert "Merge pull request #15739 from y-yagi/correct_doc_for_action_mailer_base"

This reverts commit a15704d7f35f17d34d0118546799141d6f853656, reversing
changes made to 1bd12a8609d275ad75fcc4b622ca4f5b32dc76be.

/cc @kuldeepaggarwal @y-yagi
2014-06-15 14:17:00 +02:00
yuuji.yaginuma
71da4b0c79 [ci skip] correct doc for register_preview_interceptor 2014-06-15 09:31:28 +09:00
Yves Senn
8f247871bb Merge pull request #15590 from zuhao/refactor_actionview_register_template_handler
Add unregister_template_handler to prevent leaks.

Conflicts:
	actionview/CHANGELOG.md
2014-06-12 14:06:59 +02:00
Zuhao Wan
a1dbb4e7e0 Add unregister_template_handler to prevent leaks. 2014-06-12 18:49:40 +08:00