class SequelTest::MachineWithLoopbackTest

Public Instance Methods

setup() click to toggle source
Calls superclass method
# File test/unit/integrations/sequel_test.rb, line 518
def setup
  @model = new_model do
    # Simulate timestamps plugin
    define_method(:before_update) do
      changed_columns = self.changed_columns.dup
      
      super()
      self.updated_at = Time.now if changed_columns.any?
    end
  end
  
  DB.alter_table :foo do
    add_column :updated_at, :datetime
  end
  @model.class_eval { get_db_schema(true) }
  
  @machine = StateMachine::Machine.new(@model, :initial => :parked)
  @machine.event :park
  
  @record = @model.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/sequel_test.rb, line 544
def test_should_update_record
  assert_not_equal @timestamp, @record.updated_at
end