class DataMapperTest::MachineWithScopesAndOwnerSubclassTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1856
def setup
  @resource = new_resource
  @machine = StateMachine::Machine.new(@resource, :state)
  
  @subclass = Class.new(@resource)
  DataMapperTest.const_set('Bar', @subclass)
  @resources << 'Bar'
  @subclass.auto_migrate!
  @subclass_machine = @subclass.state_machine(:state) {}
  @subclass_machine.state :parked, :idling, :first_gear
end
test_should_only_include_records_with_subclass_states_in_with_scope() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1868
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)
end
test_should_only_include_records_without_subclass_states_in_without_scope() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1875
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)
end