diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-09-25 13:26:08 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-09-25 17:28:10 +0200 |
commit | 7acf64a81bfec9f60d001a5412529088373fc4b5 (patch) | |
tree | 5fec22f71cb434ef86ce5867dc70b1bdd462f56d /railties | |
parent | 49c3ad7f7782274504fbe0818b9636d2b362a1a3 (diff) | |
download | rails-7acf64a81bfec9f60d001a5412529088373fc4b5.tar.gz rails-7acf64a81bfec9f60d001a5412529088373fc4b5.tar.bz2 rails-7acf64a81bfec9f60d001a5412529088373fc4b5.zip |
Add namespacing for observer generator
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb | 2 | ||||
-rw-r--r-- | railties/test/generators/namespaced_generators_test.rb | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb b/railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb index 03f6d5666e..cd116f5ce9 100644 --- a/railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb +++ b/railties/lib/rails/generators/test_unit/observer/templates/unit_test.rb @@ -1,8 +1,10 @@ require 'test_helper' +<% module_namespacing do -%> class <%= class_name %>ObserverTest < ActiveSupport::TestCase # Replace this with your real tests. test "the truth" do assert true end end +<% end -%> diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb index 4c85250e2c..6bf3fdf727 100644 --- a/railties/test/generators/namespaced_generators_test.rb +++ b/railties/test/generators/namespaced_generators_test.rb @@ -1,6 +1,7 @@ require 'generators/generators_test_helper' require 'rails/generators/rails/controller/controller_generator' require 'rails/generators/rails/model/model_generator' +require 'rails/generators/rails/observer/observer_generator' class NamespacedGeneratorTestCase < Rails::Generators::TestCase def setup @@ -128,3 +129,24 @@ class NamespacedModelGeneratorTest < NamespacedGeneratorTestCase assert_file "test/fixtures/test_app/accounts.yml", /name: MyString/, /age: 1/ end end + +class NamespacedObserverGeneratorTest < NamespacedGeneratorTestCase + include GeneratorsTestHelper + arguments %w(account) + tests Rails::Generators::ObserverGenerator + + def test_invokes_default_orm + run_generator + assert_file "app/models/test_app/account_observer.rb", /module TestApp/, / class AccountObserver < ActiveRecord::Observer/ + end + + def test_invokes_default_orm_with_class_path + run_generator ["admin/account"] + assert_file "app/models/test_app/admin/account_observer.rb", /module TestApp/, / class Admin::AccountObserver < ActiveRecord::Observer/ + end + + def test_invokes_default_test_framework + run_generator + assert_file "test/unit/test_app/account_observer_test.rb", /module TestApp/, / class AccountObserverTest < ActiveSupport::TestCase/ + end +end |