From d0aa0cfbd76a919e536e76d65419930fb7fe31da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 20 Nov 2009 12:16:01 -0200 Subject: Ensure generator fallbacks work even when a context is given. Signed-off-by: Yehuda Katz --- railties/lib/rails/generators.rb | 2 +- railties/test/generators_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 9f274b9edc..85c2fd52a4 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -198,7 +198,7 @@ module Rails return klass if klass end - invoke_fallbacks_for(name, base) + invoke_fallbacks_for(name, base) || invoke_fallbacks_for(context, name) end # Receives a namespace, arguments and the behavior to invoke the generator. diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index a8716d9992..4b7b80c7f5 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -150,6 +150,13 @@ class GeneratorsTest < GeneratorsTestCase assert_equal "test_unit:generators:plugin", klass.namespace end + def test_fallbacks_for_generators_on_find_by_namespace_with_context + Rails::Generators.fallbacks[:remarkable] = :test_unit + klass = Rails::Generators.find_by_namespace(:remarkable, :rails, :plugin) + assert klass + assert_equal "test_unit:generators:plugin", klass.namespace + end + def test_fallbacks_for_generators_on_invoke Rails::Generators.fallbacks[:shoulda] = :test_unit TestUnit::Generators::ModelGenerator.expects(:start).with(["Account"], {}) -- cgit v1.2.3