Sha256: 0e89336169a54afc016d254c74e1f9ce8e12df3b9421bae298cc813ad6f2722e

Contents?: true

Size: 646 Bytes

Versions: 3

Compression:

Stored size: 646 Bytes

Contents

require_relative 'test_helper'

class MachineWithLoopbackTest < BaseTestCase
  def setup
    @model = new_model do
      field :updated_at, :type => Time

      before_update do |record|
        record.updated_at = Time.now
      end
    end

    @machine = StateMachines::Machine.new(@model, :initial => :parked)
    @machine.event :park

    @record = @model.create(:updated_at => Time.now - 1)
    @transition = StateMachines::Transition.new(@record, @machine, :park, :parked, :parked)

    @timestamp = @record.updated_at
    @transition.perform
  end

  def test_should_update_record
    refute_equal @timestamp, @record.updated_at
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
state_machines-mongoid-0.2.0 test/machine_with_loopback_test.rb
state_machines-mongoid-0.1.1 test/machine_with_loopback_test.rb
state_machines-mongoid-0.1.0 test/machine_with_loopback_test.rb