diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2013-12-16 05:52:58 +0000 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2013-12-17 03:58:35 +0000 |
commit | d6dec7fcb6b8fddf8c170182d4fe64ecfc7b2261 (patch) | |
tree | c5f0fd5fccf3556fbdf4d2411fffc80896b529b9 /railties/lib/rails/generators | |
parent | 1602a70fb450aba9b5e5befe4c7bfc3344471a06 (diff) | |
download | rails-d6dec7fcb6b8fddf8c170182d4fe64ecfc7b2261.tar.gz rails-d6dec7fcb6b8fddf8c170182d4fe64ecfc7b2261.tar.bz2 rails-d6dec7fcb6b8fddf8c170182d4fe64ecfc7b2261.zip |
Add mailer previews feature based on mail_view gem
Diffstat (limited to 'railties/lib/rails/generators')
-rw-r--r-- | railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb | 9 | ||||
-rw-r--r-- | railties/lib/rails/generators/test_unit/mailer/templates/preview.rb | 11 |
2 files changed, 19 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb index 3334b189bf..85dee1a066 100644 --- a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb @@ -4,11 +4,18 @@ module TestUnit # :nodoc: module Generators # :nodoc: class MailerGenerator < Base # :nodoc: argument :actions, type: :array, default: [], banner: "method method" - check_class_collision suffix: "Test" + + def check_class_collision + class_collisions "#{class_name}Test", "#{class_name}Preview" + end def create_test_files template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_test.rb") end + + def create_preview_files + template "preview.rb", File.join('test/mailers/previews', class_path, "#{file_name}_preview.rb") + end end end end diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb b/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb new file mode 100644 index 0000000000..ac14644145 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb @@ -0,0 +1,11 @@ +<% module_namespacing do -%> +class <%= class_name %>Preview < ActionMailer::Preview +<% actions.each do |action| -%> + + def <%= action %> + <%= class_name %>.<%= action %> + end +<% end -%> + +end +<% end -%> |