提交 f821055d 编写于 作者: P Piotr Sarnacki 提交者: José Valim

Do not create table_name_prefix method on isolated module if the method already exists.

Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 799a6fa0
......@@ -363,8 +363,10 @@ def isolate_namespace(mod)
_railtie
end
define_method(:table_name_prefix) do
"#{name}_"
unless mod.respond_to?(:table_name_prefix)
define_method(:table_name_prefix) do
"#{name}_"
end
end
end
end
......
......@@ -683,5 +683,24 @@ class Engine < ::Rails::Engine
app_generators = Rails.application.config.generators.options[:rails]
assert_equal :test_unit , app_generators[:test_framework]
end
test "do not create table_name_prefix method if it already exists" do
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
def self.table_name_prefix
"foo"
end
class Engine < ::Rails::Engine
isolate_namespace(Bukkits)
end
end
RUBY
boot_rails
require "#{rails_root}/config/environment"
assert_equal "foo", Bukkits.table_name_prefix
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册