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

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

Revision 3493, 0.7 kB (checked in by david, 3 years ago)

Added reusable reloading support through the inclusion of the Relodable module that all subclasses of ActiveRecord::Base, ActiveRecord::Observer, ActiveController::Base, and ActionMailer::Base automatically gets [DHH]. Added auto-loading support for classes in modules, so Conductor::Migration will look for conductor/migration.rb and Conductor::Database::Settings will look for conductor/database/settings.rb [Nicholas Seckar]. Refactored extensions to module, class, and object in active support [DHH]

Line 
1 require 'test/unit'
2 require 'abstract_unit'
3 require 'active_support/core_ext/class/inheritable_attributes'
4
5 class A
6   include ClassInheritableAttributes
7 end
8
9 class B < A
10   write_inheritable_array "first", [ :one, :two ]
11 end
12
13 class C < A
14   write_inheritable_array "first", [ :three ]
15 end
16
17 class D < B
18   write_inheritable_array "first", [ :four ]
19 end
20
21
22 class ClassInheritableAttributesTest < Test::Unit::TestCase
23   def test_first_level
24     assert_equal [ :one, :two ], B.read_inheritable_attribute("first")
25     assert_equal [ :three ], C.read_inheritable_attribute("first")
26   end
27  
28   def test_second_level
29     assert_equal [ :one, :two, :four ], D.read_inheritable_attribute("first")
30     assert_equal [ :one, :two ], B.read_inheritable_attribute("first")
31   end
32 end
Note: See TracBrowser for help on using the browser.