aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-08-15 16:07:49 +0100
committerJon Leighton <j@jonathanleighton.com>2011-08-15 16:07:49 +0100
commit2e2f3f5a469cb441e52fb161647ea5fd27d98d81 (patch)
tree8e5dc08cd018c2be3aac5c78ceb72e0befc9713b /activesupport/test
parent57423d815b3747aa382cd3859a15bffa538525ad (diff)
downloadrails-2e2f3f5a469cb441e52fb161647ea5fd27d98d81.tar.gz
rails-2e2f3f5a469cb441e52fb161647ea5fd27d98d81.tar.bz2
rails-2e2f3f5a469cb441e52fb161647ea5fd27d98d81.zip
Add a test for delegating a method ending in '=' as this is a special case.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/module_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index a24f013d4f..d4ce81fdfa 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -27,6 +27,8 @@ module Yz
end
Somewhere = Struct.new(:street, :city) do
+ attr_accessor :name
+
protected
def protected_method
@@ -40,6 +42,7 @@ end
class Someone < Struct.new(:name, :place)
delegate :street, :city, :to_f, :protected_method, :private_method, :to => :place
+ delegate :name=, :to => :place, :prefix => true
delegate :upcase, :to => "place.city"
FAILED_DELEGATE_LINE = __LINE__ + 1
@@ -85,6 +88,11 @@ class ModuleTest < Test::Unit::TestCase
assert_equal "Chicago", @david.city
end
+ def test_delegation_to_assignment_method
+ @david.place_name = "Fred"
+ assert_equal "Fred", @david.place.name
+ end
+
def test_delegation_to_protected_method
assert_raise(NoMethodError) { @david.protected_method }
end