aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/dirty_test.rb
blob: e1a35be384d07da07bc36b136fd7cd74152ed660 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require "cases/helper"

class DirtyTest < ActiveModel::TestCase
  class DirtyModel
    include ActiveModel::Dirty
    define_attribute_methods [:name]

    def initialize
      @name = nil
    end

    def name
      @name
    end

    def name=(val)
      name_will_change!
      @name = val
    end
  end

  test "changes accessible through both strings and symbols" do
    model = DirtyModel.new
    model.name = "David"
    assert_not_nil model.changes[:name]
    assert_not_nil model.changes['name']
  end

end