aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-25 18:45:06 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-25 18:45:06 +0000
commit10220d356dccb6ccdfe3d1a91531511d6f0a9cf8 (patch)
tree03a2eee46a7294ec66b6d30c3595b82572ca82d8 /activerecord/test
parent11611c1b002243a766c86c374b812c61a5b672c7 (diff)
downloadrails-10220d356dccb6ccdfe3d1a91531511d6f0a9cf8.tar.gz
rails-10220d356dccb6ccdfe3d1a91531511d6f0a9cf8.tar.bz2
rails-10220d356dccb6ccdfe3d1a91531511d6f0a9cf8.zip
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.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@511 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/association_inheritance_reload.rb14
-rwxr-xr-xactiverecord/test/fixtures/company.rb4
2 files changed, 16 insertions, 2 deletions
diff --git a/activerecord/test/association_inheritance_reload.rb b/activerecord/test/association_inheritance_reload.rb
new file mode 100644
index 0000000000..a3d5722841
--- /dev/null
+++ b/activerecord/test/association_inheritance_reload.rb
@@ -0,0 +1,14 @@
+require 'abstract_unit'
+require 'fixtures/company'
+
+class AssociationInheritanceReloadTest < Test::Unit::TestCase
+ fixtures :companies
+
+ def test_set_attributes
+ assert_equal ["errors.add_on_empty('name', \"can't be empty\")"], Firm.read_inheritable_attribute("validate"), "Second run"
+ # ActiveRecord::Base.reset_column_information_and_inheritable_attributes_for_all_subclasses
+ remove_subclass_of(ActiveRecord::Base)
+ load 'fixtures/company.rb'
+ assert_equal ["errors.add_on_empty('name', \"can't be empty\")"], Firm.read_inheritable_attribute("validate"), "Second run"
+ end
+end \ No newline at end of file
diff --git a/activerecord/test/fixtures/company.rb b/activerecord/test/fixtures/company.rb
index 579590e909..f4df7203b8 100755
--- a/activerecord/test/fixtures/company.rb
+++ b/activerecord/test/fixtures/company.rb
@@ -12,10 +12,10 @@ class Firm < Company
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
has_many :clients_using_counter_sql, :class_name => "Client",
- :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
+ :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
:counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = #{id}'
has_many :clients_using_zero_counter_sql, :class_name => "Client",
- :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
+ :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}',
:counter_sql => 'SELECT 0 FROM companies WHERE client_of = #{id}'
has_one :account, :dependent => true