mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
3adaef8ae7
[#4308 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
29 lines
512 B
Ruby
29 lines
512 B
Ruby
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
|