From 4900587d7d862b88172d6717c9a2957a571af3b6 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Mislav=20Marohni=C4=87?= Date: Sat, 19 Apr 2008 00:01:30 +0200 Subject: [PATCH] add example for default_url_options[:host] to generated mailers --- .../components/mailer/templates/mailer.rb | 6 +++++- .../test/generators/rails_mailer_generator_test.rb | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb b/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb index 3a1724a..0c7e6be 100644 --- a/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb +++ b/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb @@ -1,4 +1,7 @@ class <%= class_name %> < ActionMailer::Base + + # change to your domain name + default_url_options[:host] = 'example.com' <% for action in actions -%> def <%= action %>(sent_at = Time.now) @@ -7,7 +10,8 @@ class <%= class_name %> < ActionMailer::Base from '' sent_on sent_at - body :action => '<%= action %>' + body :greeting => 'Hi,' end <% end -%> + end diff --git a/railties/test/generators/rails_mailer_generator_test.rb b/railties/test/generators/rails_mailer_generator_test.rb index 3cf8cda..03170c3 100644 --- a/railties/test/generators/rails_mailer_generator_test.rb +++ b/railties/test/generators/rails_mailer_generator_test.rb @@ -13,10 +13,13 @@ class RailsMailerGeneratorTest < GeneratorTestCase "from ''", "sent_on sent_at", "", - "body :action => 'reset_password'" + "body :greeting => 'Hi,'" ], body.split("\n").map{|line| line.sub(' '*4, '') } end + + assert_match /^ default_url_options\[:host\] = 'example.com'$/m, model, + 'model should include default_url_options :host declaration' end assert_generated_views_for :notifier, 'reset_password.erb' -- 1.5.3.5