aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkennyj <kennyj@gmail.com>2012-03-08 00:00:58 +0900
committerkennyj <kennyj@gmail.com>2012-03-08 00:00:58 +0900
commitcdfcbc48b25ca76fb0aa821d5ee087768e0d6522 (patch)
tree6e313fe89b1e7e1180808acc4fde7b96e967309c
parent7638004d7d23df668ec33a3c570b7865e0d06a06 (diff)
downloadrails-cdfcbc48b25ca76fb0aa821d5ee087768e0d6522.tar.gz
rails-cdfcbc48b25ca76fb0aa821d5ee087768e0d6522.tar.bz2
rails-cdfcbc48b25ca76fb0aa821d5ee087768e0d6522.zip
Don't reset inheritance_column when setting explicitly.
-rw-r--r--activerecord/lib/active_record/model_schema.rb3
-rw-r--r--activerecord/test/cases/base_test.rb10
2 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb
index 99847ac161..c85d590ce1 100644
--- a/activerecord/lib/active_record/model_schema.rb
+++ b/activerecord/lib/active_record/model_schema.rb
@@ -160,6 +160,7 @@ module ActiveRecord
# Sets the value of inheritance_column
def inheritance_column=(value)
@inheritance_column = value.to_s
+ @explicit_inheritance_column = true
end
def sequence_name
@@ -303,7 +304,7 @@ module ActiveRecord
@column_types = nil
@content_columns = nil
@dynamic_methods_hash = nil
- @inheritance_column = nil
+ @inheritance_column = nil unless defined?(@explicit_inheritance_column) && @explicit_inheritance_column
@relation = nil
end
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 01f647b261..282cb66f90 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1503,6 +1503,16 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal before_seq, after_seq unless before_seq.blank? && after_seq.blank?
end
+ def test_dont_clear_inheritnce_column_when_setting_explicitly
+ Joke.inheritance_column = "my_type"
+ before_inherit = Joke.inheritance_column
+
+ Joke.reset_column_information
+ after_inherit = Joke.inheritance_column
+
+ assert_equal before_inherit, after_inherit unless before_inherit.blank? && after_inherit.blank?
+ end
+
def test_set_table_name_symbol_converted_to_string
Joke.table_name = :cold_jokes
assert_equal 'cold_jokes', Joke.table_name