Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Changed ActiveRecord::Base.store_full_sti_class to be true by default…
… reflecting the previously announced Rails 3 default [DHH]
  • Loading branch information
dhh committed Jan 4, 2010
1 parent 6042067 commit 1459c8c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*Edge*

* Changed ActiveRecord::Base.store_full_sti_class to be true by default reflecting the previously announced Rails 3 default [DHH]

* Add Relation#delete_all. [Pratik Naik]

Item.where(:colour => 'red').delete_all
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/base.rb
Expand Up @@ -550,7 +550,7 @@ def self.reset_subclasses #:nodoc:

# Determine whether to store the full constant name including namespace when using STI
superclass_delegating_accessor :store_full_sti_class
self.store_full_sti_class = false
self.store_full_sti_class = true

# Stores the default scope for the class
class_inheritable_accessor :default_scoping, :instance_writer => false
Expand Down
3 changes: 3 additions & 0 deletions activerecord/test/cases/base_test.rb
Expand Up @@ -2138,8 +2138,11 @@ def test_to_xml_with_block
end

def test_type_name_with_module_should_handle_beginning
ActiveRecord::Base.store_full_sti_class = false
assert_equal 'ActiveRecord::Person', ActiveRecord::Base.send(:type_name_with_module, 'Person')
assert_equal '::Person', ActiveRecord::Base.send(:type_name_with_module, '::Person')
ensure
ActiveRecord::Base.store_full_sti_class = true
end

def test_to_param_should_return_string
Expand Down
3 changes: 3 additions & 0 deletions activerecord/test/cases/inheritance_test.rb
Expand Up @@ -241,6 +241,7 @@ def teardown
end

def test_instantiation_doesnt_try_to_require_corresponding_file
ActiveRecord::Base.store_full_sti_class = false
foo = Firm.find(:first).clone
foo.ruby_type = foo.type = 'FirmOnTheFly'
foo.save!
Expand All @@ -259,5 +260,7 @@ def test_instantiation_doesnt_try_to_require_corresponding_file
# And instantiate will find the existing constant rather than trying
# to require firm_on_the_fly.
assert_nothing_raised { assert_kind_of Firm::FirmOnTheFly, Firm.find(foo.id) }
ensure
ActiveRecord::Base.store_full_sti_class = true
end
end
4 changes: 4 additions & 0 deletions activerecord/test/cases/modules_test.rb
Expand Up @@ -12,13 +12,17 @@ def setup
[:Firm, :Client].each do |const|
@undefined_consts.merge! const => Object.send(:remove_const, const) if Object.const_defined?(const)
end

ActiveRecord::Base.store_full_sti_class = false
end

def teardown
# reinstate the constants that we undefined in the setup
@undefined_consts.each do |constant, value|
Object.send :const_set, constant, value unless value.nil?
end

ActiveRecord::Base.store_full_sti_class = true
end

def test_module_spanning_associations
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/reflection_test.rb
Expand Up @@ -137,6 +137,8 @@ def test_belongs_to_inferred_foreign_key_from_assoc_name
end

def test_association_reflection_in_modules
ActiveRecord::Base.store_full_sti_class = false

assert_reflection MyApplication::Business::Firm,
:clients_of_firm,
:klass => MyApplication::Business::Client,
Expand Down Expand Up @@ -172,6 +174,8 @@ def test_association_reflection_in_modules
:klass => MyApplication::Billing::Nested::Firm,
:class_name => 'Nested::Firm',
:table_name => 'companies'
ensure
ActiveRecord::Base.store_full_sti_class = true
end

def test_reflection_of_all_associations
Expand Down

0 comments on commit 1459c8c

Please sign in to comment.