class DataMapperTest::MachineWithDirtyAttributesDuringLoopbackTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 589
def setup
  @resource = new_resource
  @machine = StateMachine::Machine.new(@resource, :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 600
def test_should_include_state_in_changed_attributes
  assert_equal e = {@resource.properties[:state] => 'parked'}, @record.dirty_attributes
end
test_should_track_attribute_change() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 604
def test_should_track_attribute_change
  if Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.3')
    assert_equal e = {@resource.properties[:state] => 'parked'}, @record.original_attributes
  elsif Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.0')
    assert_equal e = {@resource.properties[:state] => 'parked-ignored'}, @record.original_attributes
  else
    assert_equal e = {:state => 'parked-ignored'},  @record.original_values
  end
end