class ActiveModelTest::MachineWithDirtyAttributeAndStateEventsTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 421 def setup @model = new_model do include ActiveModel::Dirty define_attribute_methods [:state] end @machine = StateMachine::Machine.new(@model, :action => :save, :initial => :parked) @machine.event :ignite @record = @model.create @record.state_event = 'ignite' end
test_should_include_state_in_changed_attributes()
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 433 def test_should_include_state_in_changed_attributes assert_equal %w(state), @record.changed end
test_should_not_include_state_in_changed_attributes_if_nil()
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 446 def test_should_not_include_state_in_changed_attributes_if_nil @record = @model.create @record.state_event = nil assert_equal [], @record.changed end
test_should_not_reset_changes_on_multiple_changes()
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 441 def test_should_not_reset_changes_on_multiple_changes @record.state_event = 'ignite' assert_equal %w(parked parked), @record.changes['state'] end
test_should_track_attribute_change()
click to toggle source
# File test/unit/integrations/active_model_test.rb, line 437 def test_should_track_attribute_change assert_equal %w(parked parked), @record.changes['state'] end