mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Automatically remove :generators: from namespaces.
This commit is contained in:
parent
a2e2e73c5e
commit
e75ea47434
5 changed files with 10 additions and 10 deletions
|
@ -219,7 +219,7 @@ module Rails
|
|||
builtin.sort!
|
||||
|
||||
lookup("*")
|
||||
others = subclasses.map{ |k| k.namespace.gsub(':generators:', ':') }
|
||||
others = subclasses.map{ |k| k.namespace }
|
||||
others -= Rails::Generators.builtin
|
||||
others.sort!
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ module Rails
|
|||
#
|
||||
def self.namespace(name=nil)
|
||||
return super if name
|
||||
@namespace ||= super.sub(/_generator$/, '')
|
||||
@namespace ||= super.sub(/_generator$/, '').sub(/:generators:/, ':')
|
||||
end
|
||||
|
||||
# Invoke a generator based on the value supplied by the user to the
|
||||
|
|
|
@ -20,7 +20,7 @@ class ActionsTest < GeneratorsTestCase
|
|||
end
|
||||
|
||||
def test_invoke_other_generator_with_full_namespace
|
||||
action :invoke, 'rails:generators:model', ['my_model']
|
||||
action :invoke, 'rails:model', ['my_model']
|
||||
assert_file 'app/models/my_model.rb', /MyModel/
|
||||
end
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ class AppGeneratorTest < GeneratorsTestCase
|
|||
end
|
||||
|
||||
def test_default_namespace
|
||||
assert_match "rails:generators:app", Rails::Generators::AppGenerator.namespace
|
||||
assert_match "rails:app", Rails::Generators::AppGenerator.namespace
|
||||
end
|
||||
|
||||
def test_file_is_added_for_backwards_compatibility
|
||||
|
|
|
@ -41,13 +41,13 @@ class GeneratorsTest < GeneratorsTestCase
|
|||
def test_find_by_namespace_with_base
|
||||
klass = Rails::Generators.find_by_namespace(:model, :rails)
|
||||
assert klass
|
||||
assert_equal "rails:generators:model", klass.namespace
|
||||
assert_equal "rails:model", klass.namespace
|
||||
end
|
||||
|
||||
def test_find_by_namespace_with_context
|
||||
klass = Rails::Generators.find_by_namespace(:test_unit, nil, :model)
|
||||
assert klass
|
||||
assert_equal "test_unit:generators:model", klass.namespace
|
||||
assert_equal "test_unit:model", klass.namespace
|
||||
end
|
||||
|
||||
def test_find_by_namespace_with_duplicated_name
|
||||
|
@ -65,13 +65,13 @@ class GeneratorsTest < GeneratorsTestCase
|
|||
def test_find_by_namespace_lookup_to_deep_rails_root_folders
|
||||
klass = Rails::Generators.find_by_namespace(:fixjour, :active_record)
|
||||
assert klass
|
||||
assert_equal "active_record:generators:fixjour", klass.namespace
|
||||
assert_equal "active_record:fixjour", klass.namespace
|
||||
end
|
||||
|
||||
def test_find_by_namespace_lookup_traverse_folders
|
||||
klass = Rails::Generators.find_by_namespace(:javascripts, :rails)
|
||||
assert klass
|
||||
assert_equal "rails:generators:javascripts", klass.namespace
|
||||
assert_equal "rails:javascripts", klass.namespace
|
||||
end
|
||||
|
||||
def test_find_by_namespace_lookup_to_vendor_folders
|
||||
|
@ -146,14 +146,14 @@ class GeneratorsTest < GeneratorsTestCase
|
|||
Rails::Generators.fallbacks[:remarkable] = :test_unit
|
||||
klass = Rails::Generators.find_by_namespace(:plugin, :remarkable)
|
||||
assert klass
|
||||
assert_equal "test_unit:generators:plugin", klass.namespace
|
||||
assert_equal "test_unit: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
|
||||
assert_equal "test_unit:plugin", klass.namespace
|
||||
end
|
||||
|
||||
def test_fallbacks_for_generators_on_invoke
|
||||
|
|
Loading…
Reference in a new issue