aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application
diff options
context:
space:
mode:
authorLeonard Garvey <lengarvey@gmail.com>2014-06-30 00:12:25 +1000
committerLeonard Garvey <lengarvey@gmail.com>2014-07-01 14:39:59 +1000
commit84ed7b8dfeb2ba47ca8c1b0767c85bbf200e786b (patch)
treec4c2bb39d5571fd3a4228f2ab42795997f0293b5 /railties/test/application
parentb4b6248b90ac62ece6a46bee4d36868d19444df3 (diff)
downloadrails-84ed7b8dfeb2ba47ca8c1b0767c85bbf200e786b.tar.gz
rails-84ed7b8dfeb2ba47ca8c1b0767c85bbf200e786b.tar.bz2
rails-84ed7b8dfeb2ba47ca8c1b0767c85bbf200e786b.zip
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.
Diffstat (limited to 'railties/test/application')
-rw-r--r--railties/test/application/configuration_test.rb24
-rw-r--r--railties/test/application/mailer_previews_test.rb14
2 files changed, 38 insertions, 0 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb
index 17b406f6a3..1feedb6602 100644
--- a/railties/test/application/configuration_test.rb
+++ b/railties/test/application/configuration_test.rb
@@ -965,5 +965,29 @@ module ApplicationTests
assert db_config.is_a?(Hash)
end
+
+ test 'config.mail_preview_enabled defaults to true in development' do
+ Rails.env = "development"
+ require "#{app_path}/config/environment"
+
+ assert Rails.application.config.action_mailer.preview_enabled
+ end
+
+ test 'config.mail_preview_enabled defaults to false in production' do
+ Rails.env = "production"
+ require "#{app_path}/config/environment"
+
+ assert_equal Rails.application.config.action_mailer.preview_enabled, false
+ end
+
+ test 'config.mail_preview_enabled can be set in the configuration file' do
+ Rails.env = "production"
+ add_to_config <<-RUBY
+ config.action_mailer.preview_enabled = true
+ RUBY
+ require "#{app_path}/config/environment"
+
+ assert_equal Rails.application.config.action_mailer.preview_enabled, true
+ end
end
end
diff --git a/railties/test/application/mailer_previews_test.rb b/railties/test/application/mailer_previews_test.rb
index c588fd7012..d17eb0a8d1 100644
--- a/railties/test/application/mailer_previews_test.rb
+++ b/railties/test/application/mailer_previews_test.rb
@@ -26,6 +26,20 @@ module ApplicationTests
assert_equal 404, last_response.status
end
+ test "/rails/mailers is accessible with correct configuraiton" do
+ add_to_config "config.action_mailer.preview_enabled = true"
+ app("production")
+ get "/rails/mailers"
+ assert_equal 200, last_response.status
+ end
+
+ test "/rails/mailers is not accessible with preview_enabled = false" do
+ add_to_config "config.action_mailer.preview_enabled = false"
+ app("development")
+ get "/rails/mailers"
+ assert_equal 404, last_response.status
+ end
+
test "mailer previews are loaded from the default preview_path" do
mailer 'notifier', <<-RUBY
class Notifier < ActionMailer::Base