diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-07-19 10:09:40 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-07-19 10:09:40 +0000 |
commit | 1eb79bcc3b5df2ee4e037d06835a88961eb0a429 (patch) | |
tree | d6b0f6ce28c9e5882d7d79e107d76be077773450 /activesupport/test | |
parent | a41305640722f1328ff51ce61c98371d4b648213 (diff) | |
download | rails-1eb79bcc3b5df2ee4e037d06835a88961eb0a429.tar.gz rails-1eb79bcc3b5df2ee4e037d06835a88961eb0a429.tar.bz2 rails-1eb79bcc3b5df2ee4e037d06835a88961eb0a429.zip |
Let alias_attribute work with attributes with initial capital letters (legacy columns etc). Closes #8596 [mpalmer]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7195 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/module/attribute_aliasing_test.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/module/attribute_aliasing_test.rb b/activesupport/test/core_ext/module/attribute_aliasing_test.rb index 66ddbfe62a..05f7a5c4ca 100644 --- a/activesupport/test/core_ext/module/attribute_aliasing_test.rb +++ b/activesupport/test/core_ext/module/attribute_aliasing_test.rb @@ -2,15 +2,20 @@ require File.dirname(__FILE__) + '/../../abstract_unit' module AttributeAliasing class Content - attr_accessor :title + attr_accessor :title, :Data def title? !title.nil? end + + def Data? + !self.Data.nil? + end end class Email < Content alias_attribute :subject, :title + alias_attribute :body, :Data end end @@ -28,4 +33,22 @@ class AttributeAliasingTest < Test::Unit::TestCase assert_equal "We got a long way to go", e.title assert e.title? end + + def test_aliasing_to_uppercase_attributes + # Although it's very un-Ruby, some people's AR-mapped tables have + # upper-case attributes, and when people want to alias those names + # to more sensible ones, everything goes *foof*. + e = AttributeAliasing::Email.new + + assert !e.body? + assert !e.Data? + + e.body = "No, really, this is not a joke." + assert_equal "No, really, this is not a joke.", e.Data + assert e.Data? + + e.Data = "Uppercased methods are teh suck" + assert_equal "Uppercased methods are teh suck", e.body + assert e.body? + end end |