aboutsummaryrefslogblamecommitdiffstats
path: root/activemodel/test/cases/dirty_test.rb
blob: c910cb43d4de5e913fb004705d41d1d5552d0595 (plain) (tree)




























                                                               
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 !model.changes[:name].nil?
    assert !model.changes['name'].nil?
  end

end