Skip to content

Commit

Permalink
Apply [5710] to RC
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5712 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
seckar committed Dec 10, 2006
1 parent 67ac59a commit 590b192
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions activesupport/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*SVN*

* Fix remove_constant to correctly handle constant names of the form "::A::...". References #6720. [Nicholas Seckar]


*1.4.0 RC2*

* Fixed Array#to_xml when it contains a series of hashes (each piece would get its own XML declaration) #6610 [thkarcher/cyu]
Expand Down
3 changes: 2 additions & 1 deletion activesupport/lib/active_support/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,9 @@ def to_constant_name(desc)
def remove_constant(const)
return false unless qualified_const_defined? const

const = $1 if /\A::(.*)\Z/ =~ const.to_s
names = const.split('::')
if names.size == 1 || names.first.empty? # It's under Object
if names.size == 1 # It's under Object
parent = Object
else
parent = (names[0..-2] * '::').constantize
Expand Down
2 changes: 1 addition & 1 deletion activesupport/test/core_ext/array_ext_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_to_with_instruct
{ :name => "Jason", :age => 31, :age_in_millis => BigDecimal.new('1.0') }
].to_xml(:skip_instruct => false, :indent => 0)

assert /^<\?xml [^>]*/.match(xml)
assert(/^<\?xml [^>]*/.match(xml))
assert xml.rindex(/<\?xml /) == 0
end
end
11 changes: 11 additions & 0 deletions activesupport/test/dependencies_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,15 @@ def test_autoload_doesnt_shadow_name_error
ensure
Object.send(:remove_const, :RaisesNameError) if defined?(::RaisesNameError)
end

def test_remove_constant_handles_double_colon_at_start
Object.const_set 'DeleteMe', Module.new
DeleteMe.const_set 'OrMe', Module.new
Dependencies.send :remove_constant, "::DeleteMe::OrMe"
assert ! defined?(DeleteMe::OrMe)
assert defined?(DeleteMe)
Dependencies.send :remove_constant, "::DeleteMe"
assert ! defined?(DeleteMe)
end

end

0 comments on commit 590b192

Please sign in to comment.