Sha256: 3cdf8242737fe948161f7df4b749423872b9bae48f6cec880417232f427037ce

Contents?: true

Size: 679 Bytes

Versions: 6

Compression:

Stored size: 679 Bytes

Contents

require_relative 'test_helper'

class MachineWithDirtyAttributeAndStateEventsTest < BaseTestCase
  def setup
    @model = new_model do
      include ActiveModel::Dirty
      define_attribute_methods [:state]

      def save
        super.tap do
          changes_applied
        end
      end
    end
    @machine = StateMachines::Machine.new(@model, action: :save, initial: :parked)
    @machine.event :ignite

    @record = @model.create
    @record.state_event = 'ignite'
  end

  def test_should_not_include_state_in_changed_attributes
    assert_equal [], @record.changed
  end

  def test_should_not_track_attribute_change
    assert_nil @record.changes['state']
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
state_machines-activemodel-0.9.0 test/machine_with_dirty_attribute_and_state_events_test.rb
state_machines-activemodel-0.8.0 test/machine_with_dirty_attribute_and_state_events_test.rb
state_machines-activemodel-0.7.1 test/machine_with_dirty_attribute_and_state_events_test.rb
state_machines-activemodel-0.7.0 test/machine_with_dirty_attribute_and_state_events_test.rb
state_machines-activemodel-0.6.0 test/machine_with_dirty_attribute_and_state_events_test.rb
state_machines-activemodel-0.5.1 test/machine_with_dirty_attribute_and_state_events_test.rb