mirror of
https://github.com/github/rails.git
synced 2026-02-11 06:35:10 -05:00
Revert alias_method_chain exceptions as they broke aliasing class methods.
This reverts commit be48cad9a4.
This commit is contained in:
@@ -28,10 +28,6 @@ class Module
|
||||
|
||||
with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}"
|
||||
|
||||
if method_defined?(without_method) || private_method_defined?(without_method)
|
||||
raise NameError, "#{with_method} is already in #{target}'s alias chain."
|
||||
end
|
||||
|
||||
alias_method without_method, target
|
||||
alias_method target, with_method
|
||||
|
||||
|
||||
@@ -166,19 +166,6 @@ class MethodAliasingTest < Test::Unit::TestCase
|
||||
assert_equal 'bar_with_baz', @instance.bar
|
||||
assert_equal 'bar', @instance.bar_without_baz
|
||||
end
|
||||
|
||||
def test_alias_method_chain_complains_the_second_time
|
||||
FooClassWithBarMethod.class_eval do
|
||||
def bar_with_magic; end
|
||||
alias_method_chain :bar, :magic
|
||||
end
|
||||
|
||||
assert_raise(NameError) do
|
||||
FooClassWithBarMethod.class_eval do
|
||||
alias_method_chain :bar, :magic
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_alias_method_chain_with_punctuation_method
|
||||
FooClassWithBarMethod.class_eval do
|
||||
@@ -302,5 +289,5 @@ class MethodAliasingTest < Test::Unit::TestCase
|
||||
|
||||
assert_equal 'duck_with_orange', @instance.duck
|
||||
assert FooClassWithBarMethod.public_method_defined?(:duck)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user