Sha256: 64f583fe5a3a3b715a5bec0a907ac19c332ca55eeb1dfc339610b5b49284b143

Contents?: true

Size: 925 Bytes

Versions: 14

Compression:

Stored size: 925 Bytes

Contents

require_relative 'test_helper'

class MachineWithScopesAndOwnerSubclassTest < BaseTestCase
  def setup
    @model = new_model
    @machine = StateMachines::Machine.new(@model, :state)

    @subclass = Class.new(@model)
    @subclass_machine = @subclass.state_machine(:state) {}
    @subclass_machine.state :parked, :idling, :first_gear
  end

  def test_should_only_include_records_with_subclass_states_in_with_scope
    parked = @subclass.create :state => 'parked'
    idling = @subclass.create :state => 'idling'

    assert_equal [parked, idling], @subclass.with_states(:parked, :idling).all
  end

  def test_should_only_include_records_without_subclass_states_in_without_scope
    parked = @subclass.create :state => 'parked'
    idling = @subclass.create :state => 'idling'
    first_gear = @subclass.create :state => 'first_gear'

    assert_equal [parked, idling], @subclass.without_states(:first_gear).all
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
state_machines-activerecord-0.6.0 test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.5.2 test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.5.1 test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.5.0 test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.4.1 test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.4.0 test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.4.0.pre test/machine_with_scopes_and_owner_subclass_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_scopes_and_owner_subclass_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.3.0 test/machine_with_scopes_and_owner_subclass_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-activerecord-0.2.0/test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.2.0 test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.1.0 test/machine_with_scopes_and_owner_subclass_test.rb
state_machines-activerecord-0.0.1 test/machine_with_scopes_and_owner_subclass_test.rb