aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/attributes/aliasing_test.rb
blob: 7ee25779f17837e70e2c77a81bf42c999387ad4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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