class DataMapperTest::MachineWithLoopbackTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 520
def setup
  @resource = new_resource do
    property :updated_at, DateTime
    
    # Simulate dm-timestamps
    before :update do
      return unless dirty?
      self.updated_at = DateTime.now
    end
  end
  
  @machine = StateMachine::Machine.new(@resource, :initial => :parked)
  @machine.event :park
  
  @record = @resource.create(:updated_at => Time.now - 1)
  @transition = StateMachine::Transition.new(@record, @machine, :park, :parked, :parked)
  
  @timestamp = @record.updated_at
  @transition.perform
end
test_should_update_record() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 541
def test_should_update_record
  assert_not_equal @timestamp, @record.updated_at
end