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:
|
||||
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'))
|
||||
if base.name.include?('::')
|
||||
base.source_paths << File.join(path, base.base_name, base.generator_name)
|
||||
|
@ -273,19 +272,23 @@ module Rails
|
|||
# Sets the base_name taking into account the current class namespace.
|
||||
#
|
||||
def self.base_name
|
||||
@base_name ||= self.name.split('::').first.underscore
|
||||
if name
|
||||
@base_name ||= name.split('::').first.underscore
|
||||
end
|
||||
end
|
||||
|
||||
# Removes the namespaces and get the generator name. For example,
|
||||
# Rails::Generators::MetalGenerator will return "metal" as generator name.
|
||||
#
|
||||
def self.generator_name
|
||||
if name
|
||||
@generator_name ||= begin
|
||||
klass_name = self.name.split('::').last
|
||||
klass_name = name.to_s.split('::').last
|
||||
klass_name.sub!(/Generator$/, '')
|
||||
klass_name.underscore
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Return the default value for the option name given doing a lookup in
|
||||
# Rails::Generators.options.
|
||||
|
|
|
@ -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/test_unit/model/model_generator'
|
||||
require 'mocha'
|
||||
|
|
Loading…
Reference in a new issue