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 30 31 32 33 34 35
|
# frozen_string_literal: true
require 'test_helper'
class MachineWithDirtyAttributeAndCustomAttributesDuringLoopbackTest < BaseTestCase
def setup
@model = new_model do
attribute :status, :string
def save
if valid?
changes_applied
true
else
false
end
end
end
@machine = StateMachines::Machine.new(@model, :status, initial: :parked)
@machine.event :park
@record = @model.create
@transition = StateMachines::Transition.new(@record, @machine, :park, :parked, :parked)
@transition.perform
end
def test_should_not_include_state_in_changed_attributes
assert_equal [], @record.changed
end
def test_should_not_track_attribute_changes
assert_nil @record.changes['status']
end
end
|