mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix generators tests that expect a class name
This commit is contained in:
parent
1c047be0fc
commit
cb9a1759c0
2 changed files with 11 additions and 8 deletions
|
@ -211,9 +211,8 @@ module Rails
|
||||||
#
|
#
|
||||||
def self.inherited(base) #:nodoc:
|
def self.inherited(base) #:nodoc:
|
||||||
super
|
super
|
||||||
base.source_root # Cache source root
|
|
||||||
|
|
||||||
if Rails.root && base.name !~ /Base$/
|
if base.name && base.name !~ /Base$/ && defined?(Rails.root) && Rails.root
|
||||||
path = File.expand_path(File.join(Rails.root, 'lib', 'templates'))
|
path = File.expand_path(File.join(Rails.root, 'lib', 'templates'))
|
||||||
if base.name.include?('::')
|
if base.name.include?('::')
|
||||||
base.source_paths << File.join(path, base.base_name, base.generator_name)
|
base.source_paths << File.join(path, base.base_name, base.generator_name)
|
||||||
|
@ -273,17 +272,21 @@ module Rails
|
||||||
# Sets the base_name taking into account the current class namespace.
|
# Sets the base_name taking into account the current class namespace.
|
||||||
#
|
#
|
||||||
def self.base_name
|
def self.base_name
|
||||||
@base_name ||= self.name.split('::').first.underscore
|
if name
|
||||||
|
@base_name ||= name.split('::').first.underscore
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Removes the namespaces and get the generator name. For example,
|
# Removes the namespaces and get the generator name. For example,
|
||||||
# Rails::Generators::MetalGenerator will return "metal" as generator name.
|
# Rails::Generators::MetalGenerator will return "metal" as generator name.
|
||||||
#
|
#
|
||||||
def self.generator_name
|
def self.generator_name
|
||||||
@generator_name ||= begin
|
if name
|
||||||
klass_name = self.name.split('::').last
|
@generator_name ||= begin
|
||||||
klass_name.sub!(/Generator$/, '')
|
klass_name = name.to_s.split('::').last
|
||||||
klass_name.underscore
|
klass_name.sub!(/Generator$/, '')
|
||||||
|
klass_name.underscore
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
require File.join(File.dirname(__FILE__), 'generators', 'generators_test_helper')
|
require 'generators/generators_test_helper'
|
||||||
require 'rails/generators/rails/model/model_generator'
|
require 'rails/generators/rails/model/model_generator'
|
||||||
require 'rails/generators/test_unit/model/model_generator'
|
require 'rails/generators/test_unit/model/model_generator'
|
||||||
require 'mocha'
|
require 'mocha'
|
||||||
|
|
Loading…
Reference in a new issue