diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-11-21 02:20:09 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-11-22 13:43:12 +0100 |
commit | f821055dc7bead5ab348f63279cd4321d4d9c3c8 (patch) | |
tree | 19061911f358091c8a876c8c001ff8642729058d | |
parent | 799a6fa047aa44ab4813dbf9328941b6d620e9b6 (diff) | |
download | rails-f821055dc7bead5ab348f63279cd4321d4d9c3c8.tar.gz rails-f821055dc7bead5ab348f63279cd4321d4d9c3c8.tar.bz2 rails-f821055dc7bead5ab348f63279cd4321d4d9c3c8.zip |
Do not create table_name_prefix method on isolated module if the method already exists.
Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r-- | railties/lib/rails/engine.rb | 6 | ||||
-rw-r--r-- | railties/test/railties/engine_test.rb | 19 |
2 files changed, 23 insertions, 2 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 62fb781c19..85fa4424c4 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -363,8 +363,10 @@ module Rails _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 diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 701b6816c8..7548c6318e 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -683,5 +683,24 @@ module RailtiesTest 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 |