class MongoidTest::MachineWithDirtyAttributeAndStateEventsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 642
def setup
  @model = new_model
  @machine = StateMachine::Machine.new(@model, :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/mongoid_test.rb, line 651
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/mongoid_test.rb, line 664
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/mongoid_test.rb, line 659
def test_should_not_reset_changes_on_multiple_changes
  @record.state_event = 'ignite'
  assert_equal %w(parked parked), @record.send(:attribute_change, 'state')
end
test_should_track_attribute_change() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 655
def test_should_track_attribute_change
  assert_equal %w(parked parked), @record.send(:attribute_change, 'state')
end