mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update Mailer generator to use 1.9 styled hash when run on Ruby 1.9
As always, you can run `--old-style-hash` to override that.
This commit is contained in:
parent
a4a338167e
commit
f2769ebd7e
3 changed files with 28 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
||||||
<% module_namespacing do -%>
|
<% module_namespacing do -%>
|
||||||
class <%= class_name %> < ActionMailer::Base
|
class <%= class_name %> < ActionMailer::Base
|
||||||
default :from => "from@example.com"
|
default <%= key_value :from, '"from@example.com"' %>
|
||||||
<% for action in actions -%>
|
<% for action in actions -%>
|
||||||
|
|
||||||
# Subject can be set in your I18n file at config/locales/en.yml
|
# Subject can be set in your I18n file at config/locales/en.yml
|
||||||
|
@ -11,7 +11,7 @@ class <%= class_name %> < ActionMailer::Base
|
||||||
def <%= action %>
|
def <%= action %>
|
||||||
@greeting = "Hi"
|
@greeting = "Hi"
|
||||||
|
|
||||||
mail :to => "to@example.org"
|
mail <%= key_value :to, '"to@example.org"' %>
|
||||||
end
|
end
|
||||||
<% end -%>
|
<% end -%>
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,7 +30,7 @@ by the prototype-rails gem. [fxn]
|
||||||
|
|
||||||
* jQuery is the new default JavaScript library. [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:
|
So instead of creating something like:
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,11 @@ class MailerGeneratorTest < Rails::Generators::TestCase
|
||||||
run_generator
|
run_generator
|
||||||
assert_file "app/mailers/notifier.rb" do |mailer|
|
assert_file "app/mailers/notifier.rb" do |mailer|
|
||||||
assert_match /class Notifier < ActionMailer::Base/, mailer
|
assert_match /class Notifier < ActionMailer::Base/, mailer
|
||||||
|
if RUBY_VERSION < "1.9"
|
||||||
assert_match /default :from => "from@example.com"/, mailer
|
assert_match /default :from => "from@example.com"/, mailer
|
||||||
|
else
|
||||||
|
assert_match /default from: "from@example.com"/, mailer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,15 +77,33 @@ class MailerGeneratorTest < Rails::Generators::TestCase
|
||||||
|
|
||||||
assert_file "app/mailers/notifier.rb" do |mailer|
|
assert_file "app/mailers/notifier.rb" do |mailer|
|
||||||
assert_instance_method :foo, mailer do |foo|
|
assert_instance_method :foo, mailer do |foo|
|
||||||
|
if RUBY_VERSION < "1.9"
|
||||||
assert_match /mail :to => "to@example.org"/, foo
|
assert_match /mail :to => "to@example.org"/, foo
|
||||||
|
else
|
||||||
|
assert_match /mail to: "to@example.org"/, foo
|
||||||
|
end
|
||||||
assert_match /@greeting = "Hi"/, foo
|
assert_match /@greeting = "Hi"/, foo
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_instance_method :bar, mailer do |bar|
|
assert_instance_method :bar, mailer do |bar|
|
||||||
|
if RUBY_VERSION < "1.9"
|
||||||
assert_match /mail :to => "to@example.org"/, bar
|
assert_match /mail :to => "to@example.org"/, bar
|
||||||
|
else
|
||||||
|
assert_match /mail to: "to@example.org"/, bar
|
||||||
|
end
|
||||||
assert_match /@greeting = "Hi"/, bar
|
assert_match /@greeting = "Hi"/, bar
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue