From 9d00b0ce858a6f642089a477e7d39fb3f9cf6777 Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson <david@loudthinking.com>
Date: Thu, 3 Aug 2006 18:47:43 +0000
Subject: Added Module#alias_attribute [Jamis/DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4653 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
---
 .../core_ext/module/attribute_aliasing_test.rb     | 31 ++++++++++++++++++++++
 activesupport/test/core_ext/module_test.rb         |  1 -
 2 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 activesupport/test/core_ext/module/attribute_aliasing_test.rb

(limited to 'activesupport/test')

diff --git a/activesupport/test/core_ext/module/attribute_aliasing_test.rb b/activesupport/test/core_ext/module/attribute_aliasing_test.rb
new file mode 100644
index 0000000000..66ddbfe62a
--- /dev/null
+++ b/activesupport/test/core_ext/module/attribute_aliasing_test.rb
@@ -0,0 +1,31 @@
+require File.dirname(__FILE__) + '/../../abstract_unit'
+
+module AttributeAliasing
+  class Content
+    attr_accessor :title
+  
+    def title?
+      !title.nil?
+    end
+  end
+
+  class Email < Content
+    alias_attribute :subject, :title
+  end
+end
+
+class AttributeAliasingTest < Test::Unit::TestCase
+  def test_attribute_alias
+    e = AttributeAliasing::Email.new
+
+    assert !e.subject?
+
+    e.title = "Upgrade computer"
+    assert_equal "Upgrade computer", e.subject
+    assert e.subject?
+
+    e.subject = "We got a long way to go"
+    assert_equal "We got a long way to go", e.title
+    assert e.title?
+  end
+end
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index 5507ef3120..cdcb511e45 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -117,7 +117,6 @@ module BarMethodAliaser
 end
 
 class MethodAliasingTest < Test::Unit::TestCase
-
   def setup
     Object.const_set(:FooClassWithBarMethod, Class.new)
     FooClassWithBarMethod.send(:define_method, 'bar', Proc.new { 'bar' })
-- 
cgit v1.2.3