diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-13 15:29:36 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-13 15:29:36 -0700 |
commit | 0307fc70add3337a9371ab40d7635372511a8f17 (patch) | |
tree | 3b18f502faa772a3191898c9b5618441727ed752 | |
parent | a4a338167e752a4d92c64c7133ff4c975155ab7b (diff) | |
parent | f2769ebd7eaa4bdc9aabfbff23c1ef3cbc7d4f9f (diff) | |
download | rails-0307fc70add3337a9371ab40d7635372511a8f17.tar.gz rails-0307fc70add3337a9371ab40d7635372511a8f17.tar.bz2 rails-0307fc70add3337a9371ab40d7635372511a8f17.zip |
Merge pull request #540 from sikachu/mailer_generator_1_9_style
Update Mailer generator to use 1.9 styled hash when run on Ruby 1.9
-rw-r--r-- | actionmailer/lib/rails/generators/mailer/templates/mailer.rb | 4 | ||||
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/test/generators/mailer_generator_test.rb | 28 |
3 files changed, 28 insertions, 6 deletions
diff --git a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb index 370a508cad..88b074cef5 100644 --- a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb +++ b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb @@ -1,6 +1,6 @@ <% module_namespacing do -%> class <%= class_name %> < ActionMailer::Base - default :from => "from@example.com" + default <%= key_value :from, '"from@example.com"' %> <% for action in actions -%> # Subject can be set in your I18n file at config/locales/en.yml @@ -11,7 +11,7 @@ class <%= class_name %> < ActionMailer::Base def <%= action %> @greeting = "Hi" - mail :to => "to@example.org" + mail <%= key_value :to, '"to@example.org"' %> end <% end -%> end diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 9bdf41731b..f93a7d918b 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -30,7 +30,7 @@ by the prototype-rails gem. [fxn] * jQuery is the new default JavaScript library. [fxn] -* Changed scaffold and app generator to create Ruby 1.9 style hash when running on Ruby 1.9 [Prem Sichanugrist] +* Changed scaffold, application, and mailer generator to create Ruby 1.9 style hash when running on Ruby 1.9 [Prem Sichanugrist] So instead of creating something like: diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index f4fdc46328..bf1cfe5305 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -10,7 +10,11 @@ class MailerGeneratorTest < Rails::Generators::TestCase run_generator assert_file "app/mailers/notifier.rb" do |mailer| assert_match /class Notifier < ActionMailer::Base/, mailer - assert_match /default :from => "from@example.com"/, mailer + if RUBY_VERSION < "1.9" + assert_match /default :from => "from@example.com"/, mailer + else + assert_match /default from: "from@example.com"/, mailer + end end end @@ -73,15 +77,33 @@ class MailerGeneratorTest < Rails::Generators::TestCase assert_file "app/mailers/notifier.rb" do |mailer| assert_instance_method :foo, mailer do |foo| - assert_match /mail :to => "to@example.org"/, foo + if RUBY_VERSION < "1.9" + assert_match /mail :to => "to@example.org"/, foo + else + assert_match /mail to: "to@example.org"/, foo + end assert_match /@greeting = "Hi"/, foo end assert_instance_method :bar, mailer do |bar| - assert_match /mail :to => "to@example.org"/, bar + if RUBY_VERSION < "1.9" + assert_match /mail :to => "to@example.org"/, bar + else + assert_match /mail to: "to@example.org"/, bar + end assert_match /@greeting = "Hi"/, bar end end + end + def test_force_old_style_hash + run_generator ["notifier", "foo", "--old-style-hash"] + assert_file "app/mailers/notifier.rb" do |mailer| + assert_match /default :from => "from@example.com"/, mailer + + assert_instance_method :foo, mailer do |foo| + assert_match /mail :to => "to@example.org"/, foo + end + end end end |