diff options
author | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-25 13:13:29 +0100 |
---|---|---|
committer | José Valim and Mikel Lindsaar <pair@programming.com> | 2010-01-25 13:20:32 +0100 |
commit | 9cb3ca1d29eb770c1a7adac3798666847fceee2b (patch) | |
tree | 70aeb2f12e00d98c13d7f55bdd9d445d4223fcfd /railties/lib/generators | |
parent | ad8f5d4106c77ed1d054bf3b29bec94df557a7cd (diff) | |
download | rails-9cb3ca1d29eb770c1a7adac3798666847fceee2b.tar.gz rails-9cb3ca1d29eb770c1a7adac3798666847fceee2b.tar.bz2 rails-9cb3ca1d29eb770c1a7adac3798666847fceee2b.zip |
Change mailer generator templates and refactor the whole naming schema.
Diffstat (limited to 'railties/lib/generators')
6 files changed, 26 insertions, 19 deletions
diff --git a/railties/lib/generators/erb/mailer/templates/view.erb b/railties/lib/generators/erb/mailer/templates/view.erb index fcce7bd805..6d597256a6 100644 --- a/railties/lib/generators/erb/mailer/templates/view.erb +++ b/railties/lib/generators/erb/mailer/templates/view.erb @@ -1,3 +1,3 @@ <%= class_name %>#<%= @action %> -Find me in app/views/<%= @path %> +<%%= @greeting %>, find me in app/views/<%= @path %> diff --git a/railties/lib/generators/rails/mailer/templates/mailer.rb b/railties/lib/generators/rails/mailer/templates/mailer.rb index 90e0b712d6..5e7ef42370 100644 --- a/railties/lib/generators/rails/mailer/templates/mailer.rb +++ b/railties/lib/generators/rails/mailer/templates/mailer.rb @@ -1,14 +1,15 @@ class <%= class_name %> < ActionMailer::Base + delivers_from "mail@<%= application_name %>.com" <% for action in actions -%> - def <%= action %>(sent_at = Time.now) - subject '<%= class_name %>#<%= action %>' - recipients '' - from '' - sent_on sent_at - - body :greeting => 'Hi,' + # Subject can be set in your I18n file at config/locales/en.yml + # with the following lookup: + # + # en.actionmailer.<%= file_name %>.<%= action %>.subject + # + def <%= action %> + @greeting = "Hi" + mail(:to => "") end - <% end -%> -end +end
\ No newline at end of file diff --git a/railties/lib/generators/rails/resource/resource_generator.rb b/railties/lib/generators/rails/resource/resource_generator.rb index 43c7cc85f4..5acb839f39 100644 --- a/railties/lib/generators/rails/resource/resource_generator.rb +++ b/railties/lib/generators/rails/resource/resource_generator.rb @@ -6,8 +6,8 @@ module Rails class ResourceGenerator < ModelGenerator #metagenerator include ResourceHelpers - hook_for :resource_controller, :required => true do |base, controller| - base.invoke controller, [ base.controller_name, base.options[:actions] ] + hook_for :resource_controller, :required => true do |controller| + invoke controller, [ controller_name, options[:actions] ] end class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [], diff --git a/railties/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb b/railties/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb index e544e29892..49af2974cd 100644 --- a/railties/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb +++ b/railties/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb @@ -18,9 +18,9 @@ module Rails hook_for :template_engine, :test_framework, :as => :scaffold - # Invoke the helper using the controller (pluralized) name. - hook_for :helper, :as => :scaffold do |base, invoked| - base.invoke invoked, [ base.controller_name ] + # Invoke the helper using the controller name (pluralized) + hook_for :helper, :as => :scaffold do |invoked| + invoke invoked, [ controller_name ] end end end diff --git a/railties/lib/generators/test_unit/mailer/templates/fixture b/railties/lib/generators/test_unit/mailer/templates/fixture index fcce7bd805..171648d6fd 100644 --- a/railties/lib/generators/test_unit/mailer/templates/fixture +++ b/railties/lib/generators/test_unit/mailer/templates/fixture @@ -1,3 +1,3 @@ <%= class_name %>#<%= @action %> -Find me in app/views/<%= @path %> +Hi, find me in app/views/<%= @path %> diff --git a/railties/lib/generators/test_unit/mailer/templates/functional_test.rb b/railties/lib/generators/test_unit/mailer/templates/functional_test.rb index d7366fea5f..2f694e431c 100644 --- a/railties/lib/generators/test_unit/mailer/templates/functional_test.rb +++ b/railties/lib/generators/test_unit/mailer/templates/functional_test.rb @@ -3,11 +3,17 @@ require 'test_helper' class <%= class_name %>Test < ActionMailer::TestCase <% for action in actions -%> test "<%= action %>" do - @expected.subject = '<%= class_name %>#<%= action %>' - @expected.body = read_fixture('<%= action %>') + @actual = <%= class_name %>.<%= action %> + + @expected.subject = <%= action.to_s.humanize.inspect %> + @expected.body = read_fixture("<%= action %>") @expected.date = Time.now - assert_equal @expected, <%= class_name %>.create_<%= action %>(@expected.date) + assert_difference "<%= class_name %>.deliveries.size" do + @actual.deliver + end + + assert_equal @expected.encoded, @actual.encoded end <% end -%> |