Sha256: cff778b5b9c1996749b1ad897bd5289d3a6c7c731f686e9e3223f1b908e84224

Contents?: true

Size: 561 Bytes

Versions: 19

Compression:

Stored size: 561 Bytes

Contents

require_relative 'test_helper'

class MachineWithValidationsAndCustomAttributeTest < BaseTestCase
  def setup
    @model = new_model { include ActiveModel::Validations }

    @machine = StateMachines::Machine.new(@model, :status, attribute: :state)
    @machine.state :parked

    @record = @model.new
  end

  def test_should_add_validation_errors_to_custom_attribute
    @record.state = 'invalid'

    assert !@record.valid?
    assert_equal ['State is invalid'], @record.errors.full_messages

    @record.state = 'parked'
    assert @record.valid?
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
state_machines-activemodel-0.9.0 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.8.0 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.7.1 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.7.0 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.6.0 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.5.1 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.5.0 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.4.1 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.4.0 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.4.0.pre test/machine_with_validations_and_custom_attribute_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-activemodel-0.1.2/test/machine_with_validations_and_custom_attribute_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-activemodel-0.1.2/test/machine_with_validations_and_custom_attribute_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-activemodel-0.1.2/test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.3.0 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.2.0 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.1.2 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.1.1 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.1.0 test/machine_with_validations_and_custom_attribute_test.rb
state_machines-activemodel-0.0.3 test/machine_with_validations_and_custom_attribute_test.rb