Changeset 1125
- Timestamp:
- 04/10/05 15:01:35 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/routing.rb (modified) (1 diff)
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/dependencies.rb (modified) (4 diffs)
- trunk/activesupport/test/loading_module_tests.rb (modified) (6 diffs)
- trunk/activesupport/test/loading_module/content_controller.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r1108 r1125 1 1 *SVN* 2 3 * Fixed that in some circumstances controllers outside of modules may have hidden ones inside modules. For example, admin/content might have been hidden by /content. #1075 [Nicholas Seckar] 2 4 3 5 * Added JavascriptHelper#periodically_call_remote in order to create areas of a page that update automatically at a set interval #945 [Jon Tirsen] trunk/actionpack/lib/action_controller/routing.rb
r984 r1125 163 163 return nil, nil unless /^[A-Z][_a-zA-Z\d]*$/ =~ name 164 164 controller_name = name + "Controller" 165 return mod.const_get(controller_name), path[length..-1] if mod.const_available? controller_name165 return eval("mod::#{controller_name}"), path[length..-1] if mod.const_available? controller_name 166 166 return nil, nil unless mod.const_available? name 167 167 [mod.const_get(name), length + 1] trunk/activesupport/CHANGELOG
r1101 r1125 1 1 *SVN* 2 3 * Fixed that in some circumstances controllers outside of modules may have hidden ones inside modules. For example, admin/content might have been hidden by /content. #1075 [Nicholas Seckar] 2 4 3 5 * Fixed inflection of perspectives and similar words #1045 [thijs@vandervossen.net] trunk/activesupport/lib/active_support/dependencies.rb
r1057 r1125 56 56 RootLoadingModule.new(*load_paths) 57 57 end 58 58 59 59 def initialize(root, path=[]) 60 60 @path = path.clone.freeze … … 82 82 self.const_set name, new_module 83 83 if self.root? 84 raise NameError, "Cannot load controller module named #{name}: An object of type #{Object.const_get(name).class.to_s} already exists." \ 85 if Object.const_defined?(name) 86 Object.const_set(name, new_module) 84 if Object.const_defined?(name) 85 msg = "Cannot load module #{name}: Object::#{name} is set to #{Object.const_get(name).inspect}" 86 raise NameError, msg 87 end 88 Object.const_set(name, new_module) 87 89 end 88 90 break … … 95 97 end 96 98 end 97 99 98 100 return self.const_defined?(name) 99 101 end … … 125 127 def clear! 126 128 constants.each do |name| 127 Object.send(:remove_const, name) if Object.const_defined?(name) 129 Object.send(:remove_const, name) if Object.const_defined?(name) && Object.const_get(name).object_id == self.const_get(name).object_id 128 130 self.send(:remove_const, name) 129 131 end trunk/activesupport/test/loading_module_tests.rb
r711 r1125 9 9 def setup 10 10 @loading_module = Dependencies::LoadingModule.root(STAGING_DIRECTORY) 11 Object.send(:remove_const, :Controllers) if Object.const_defined?(:Controllers) 11 12 Object.const_set(:Controllers, @loading_module) 12 13 end 13 14 def teardown 14 @loading_module.clear15 15 Object.send :remove_const, :Controllers 16 @loading_module.clear! 17 Dependencies.clear 16 18 end 17 19 … … 30 32 end 31 33 34 def test_nested_const_available 35 assert @loading_module::Admin.const_available?(:AccessController) 36 assert @loading_module::Admin.const_available?(:UserController) 37 assert @loading_module::Admin.const_available?(:ContentController) 38 assert ! @loading_module::Admin.const_available?(:ResourceController) 39 end 40 41 def test_nested_module_export 42 @loading_module::Admin 43 assert_equal @loading_module::Admin.object_id, Object::Admin.object_id 44 assert_equal @loading_module::Admin.object_id, Controllers::Admin.object_id 45 end 46 32 47 def test_const_load_module 33 48 assert @loading_module.const_load!(:Admin) … … 43 58 def test_const_load_nested_controller 44 59 assert @loading_module.const_load!(:Admin) 60 assert_kind_of Dependencies::LoadingModule, @loading_module::Admin 45 61 assert @loading_module::Admin.const_available?(:UserController) 46 assert @loading_module::Admin.const_load!(:UserController)47 62 assert_kind_of Class, @loading_module::Admin::UserController 48 63 end … … 62 77 assert_raises(NameError) {@loading_module::Admin::FishController} 63 78 end 79 80 def test_name_clash 81 assert ! @loading_module::const_defined?(:ContentController) 82 assert_equal :outer, @loading_module::ContentController.new.identifier 83 assert ! @loading_module::Admin.const_defined?(:ContentController) 84 assert_equal :inner, @loading_module::Admin::ContentController.new.identifier 85 assert @loading_module::ContentController.object_id != @loading_module::Admin::ContentController.object_id 86 end 87 88 def test_name_clash_other_way 89 assert ! @loading_module::Admin.const_defined?(:ContentController) 90 assert_equal :inner, @loading_module::Admin::ContentController.new.identifier 91 assert ! @loading_module::const_defined?(:ContentController) 92 assert_equal :outer, @loading_module::ContentController.new.identifier 93 assert @loading_module::ContentController.object_id != @loading_module::Admin::ContentController.object_id 94 end 64 95 end 65 96 … … 70 101 end 71 102 def teardown 72 @loading_module.clear73 103 Object.send :remove_const, :Controllers 104 @loading_module.clear! 105 Dependencies.clear 74 106 end 75 107 … … 82 114 assert_kind_of Module, @loading_module::List 83 115 assert_kind_of Dependencies::LoadingModule, @loading_module::List 84 assert @loading_module::List.const_load! :ListController116 assert @loading_module::List.const_load!(:ListController) 85 117 assert_kind_of Class, @loading_module::List::ListController 86 118 end trunk/activesupport/test/loading_module/content_controller.rb
r617 r1125 1 1 class ContentController 2 def identifier() :outer end 2 3 end