From c7255386cd3d6de037a9b08b635f9ac299608ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 19 Jan 2010 00:49:04 +0100 Subject: `script/generate mailer Notifier` will now create a mailer at app/mailers. --- railties/lib/generators/rails/mailer/USAGE | 4 ++-- .../lib/generators/rails/mailer/mailer_generator.rb | 2 +- .../generators/test_unit/mailer/mailer_generator.rb | 2 +- .../test_unit/mailer/templates/functional_test.rb | 20 ++++++++++++++++++++ .../test_unit/mailer/templates/unit_test.rb | 20 -------------------- railties/test/generators/mailer_generator_test.rb | 8 ++++---- 6 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 railties/lib/generators/test_unit/mailer/templates/functional_test.rb delete mode 100644 railties/lib/generators/test_unit/mailer/templates/unit_test.rb (limited to 'railties') diff --git a/railties/lib/generators/rails/mailer/USAGE b/railties/lib/generators/rails/mailer/USAGE index c56095b2c8..4b0b8ddc3b 100644 --- a/railties/lib/generators/rails/mailer/USAGE +++ b/railties/lib/generators/rails/mailer/USAGE @@ -9,7 +9,7 @@ Example: `./script/generate mailer Notifications signup forgot_password invoice` creates a Notifications mailer class, views, test, and fixtures: - Mailer: app/models/notifications.rb + Mailer: app/mailers/notifications.rb Views: app/views/notifications/signup.erb [...] - Test: test/unit/test/unit/notifications_test.rb + Test: test/functional/notifications_test.rb Fixtures: test/fixtures/notifications/signup [...] diff --git a/railties/lib/generators/rails/mailer/mailer_generator.rb b/railties/lib/generators/rails/mailer/mailer_generator.rb index 33f1665b83..8993181d79 100644 --- a/railties/lib/generators/rails/mailer/mailer_generator.rb +++ b/railties/lib/generators/rails/mailer/mailer_generator.rb @@ -5,7 +5,7 @@ module Rails check_class_collision def create_mailer_file - template "mailer.rb", File.join('app/models', class_path, "#{file_name}.rb") + template "mailer.rb", File.join('app/mailers', class_path, "#{file_name}.rb") end hook_for :template_engine, :test_framework diff --git a/railties/lib/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/generators/test_unit/mailer/mailer_generator.rb index ef350a6224..a0d73db1b0 100644 --- a/railties/lib/generators/test_unit/mailer/mailer_generator.rb +++ b/railties/lib/generators/test_unit/mailer/mailer_generator.rb @@ -7,7 +7,7 @@ module TestUnit check_class_collision :suffix => "Test" def create_test_files - template "unit_test.rb", File.join('test/unit', class_path, "#{file_name}_test.rb") + template "functional_test.rb", File.join('test/functional', class_path, "#{file_name}_test.rb") end def create_fixtures_files diff --git a/railties/lib/generators/test_unit/mailer/templates/functional_test.rb b/railties/lib/generators/test_unit/mailer/templates/functional_test.rb new file mode 100644 index 0000000000..4de94076e9 --- /dev/null +++ b/railties/lib/generators/test_unit/mailer/templates/functional_test.rb @@ -0,0 +1,20 @@ +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 %>') + @expected.date = Time.now + + assert_equal @expected.encoded, <%= class_name %>.create_<%= action %>(@expected.date).encoded + end + +<% end -%> +<% if actions.blank? -%> + # replace this with your real tests + test "the truth" do + assert true + end +<% end -%> +end diff --git a/railties/lib/generators/test_unit/mailer/templates/unit_test.rb b/railties/lib/generators/test_unit/mailer/templates/unit_test.rb deleted file mode 100644 index 4de94076e9..0000000000 --- a/railties/lib/generators/test_unit/mailer/templates/unit_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -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 %>') - @expected.date = Time.now - - assert_equal @expected.encoded, <%= class_name %>.create_<%= action %>(@expected.date).encoded - end - -<% end -%> -<% if actions.blank? -%> - # replace this with your real tests - test "the truth" do - assert true - end -<% end -%> -end diff --git a/railties/test/generators/mailer_generator_test.rb b/railties/test/generators/mailer_generator_test.rb index deabfb432c..dfc3130f77 100644 --- a/railties/test/generators/mailer_generator_test.rb +++ b/railties/test/generators/mailer_generator_test.rb @@ -7,7 +7,7 @@ class MailerGeneratorTest < Rails::Generators::TestCase def test_mailer_skeleton_is_created run_generator - assert_file "app/models/notifier.rb", /class Notifier < ActionMailer::Base/ + assert_file "app/mailers/notifier.rb", /class Notifier < ActionMailer::Base/ end def test_check_class_collision @@ -17,7 +17,7 @@ class MailerGeneratorTest < Rails::Generators::TestCase def test_invokes_default_test_framework run_generator - assert_file "test/unit/notifier_test.rb", /class NotifierTest < ActionMailer::TestCase/ + assert_file "test/functional/notifier_test.rb", /class NotifierTest < ActionMailer::TestCase/ assert_file "test/fixtures/notifier/foo", /app\/views\/notifier\/foo/ assert_file "test/fixtures/notifier/bar", /app\/views\/notifier\/bar/ end @@ -40,7 +40,7 @@ class MailerGeneratorTest < Rails::Generators::TestCase def test_actions_are_turned_into_methods run_generator - assert_file "app/models/notifier.rb", /def foo/ - assert_file "app/models/notifier.rb", /def bar/ + assert_file "app/mailers/notifier.rb", /def foo/ + assert_file "app/mailers/notifier.rb", /def bar/ end end -- cgit v1.2.3