aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/attributes/aliasing_test.rb
diff options
context:
space:
mode:
authorEric Chapweske <eric@chapweske.com>2009-10-17 12:37:15 -0500
committerJoshua Peek <josh@joshpeek.com>2009-10-17 12:37:15 -0500
commitf936a1f100e75082081e782e5cceb272885c2df7 (patch)
tree6c5091faa38f15765b3be153141b81d693b02d18 /activerecord/test/cases/attributes/aliasing_test.rb
parente13d232150921cdf0ec3d713caefa628d235152e (diff)
downloadrails-f936a1f100e75082081e782e5cceb272885c2df7.tar.gz
rails-f936a1f100e75082081e782e5cceb272885c2df7.tar.bz2
rails-f936a1f100e75082081e782e5cceb272885c2df7.zip
Refactoring attributes/types [#3348 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activerecord/test/cases/attributes/aliasing_test.rb')
-rw-r--r--activerecord/test/cases/attributes/aliasing_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/attributes/aliasing_test.rb b/activerecord/test/cases/attributes/aliasing_test.rb
new file mode 100644
index 0000000000..7ee25779f1
--- /dev/null
+++ b/activerecord/test/cases/attributes/aliasing_test.rb
@@ -0,0 +1,20 @@
+require "cases/helper"
+
+class AliasingTest < ActiveRecord::TestCase
+
+ class AliasingAttributes < Hash
+ include ActiveRecord::Attributes::Aliasing
+ end
+
+ test "attribute access with aliasing" do
+ attributes = AliasingAttributes.new
+ attributes[:name] = 'Batman'
+ attributes.aliases['nickname'] = 'name'
+
+ assert_equal 'Batman', attributes[:name], "Symbols should point to Strings"
+ assert_equal 'Batman', attributes['name']
+ assert_equal 'Batman', attributes['nickname']
+ assert_equal 'Batman', attributes[:nickname]
+ end
+
+end