Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/branches/2-1-caching/activerecord/test/association_inheritance_reload.rb

Revision 511, 0.6 kB (checked in by david, 4 years ago)

Fixed dependency reloading by switching to a remove_const approach where all Active Records, Active Record Observers, and Action Controllers are reloading by undefining their classes. This enables you to remove methods in all three types and see the change reflected immediately and it fixes #539. This also means that only those three types of classes will benefit from the const_missing and reloading approach. If you want other classes (like some in lib/) to reload, you must use require_dependency to do it.

Line 
1 require 'abstract_unit'
2 require 'fixtures/company'
3
4 class AssociationInheritanceReloadTest < Test::Unit::TestCase
5   fixtures :companies
6
7   def test_set_attributes
8     assert_equal ["errors.add_on_empty('name', \"can't be empty\")"], Firm.read_inheritable_attribute("validate"), "Second run"
9     # ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
10     remove_subclass_of(ActiveRecord::Base)
11     load 'fixtures/company.rb'
12     assert_equal ["errors.add_on_empty('name', \"can't be empty\")"], Firm.read_inheritable_attribute("validate"), "Second run"
13   end
14 end
Note: See TracBrowser for help on using the browser.