class DataMapperTest::MachineWithDirtyAttributeAndCustomAttributesDuringLoopbackTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 655
def setup
  @resource = new_resource do
    property :status, String, :default => 'idling'
  end
  @machine = StateMachine::Machine.new(@resource, :status, :initial => :parked)
  @machine.event :park
  
  @record = @resource.create
  
  @transition = StateMachine::Transition.new(@record, @machine, :park, :parked, :parked)
  @transition.perform(false)
end
test_should_include_state_in_changed_attributes() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 668
def test_should_include_state_in_changed_attributes
  assert_equal e = {@resource.properties[:status] => 'parked'}, @record.dirty_attributes
end
test_should_track_attribute_changes() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 672
def test_should_track_attribute_changes
  if Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.3')
    assert_equal e = {@resource.properties[:status] => 'parked'}, @record.original_attributes
  elsif Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.0')
    assert_equal e = {@resource.properties[:status] => 'parked-ignored'}, @record.original_attributes
  else
    assert_equal e = {:status => 'parked-ignored'},  @record.original_values
  end
end