class DataMapperTest::MachineWithScopesAndJoinsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1900
def setup
  @company = new_resource(:company)
  
  @vehicle = new_resource(:vehicle) do
    property :company_id, Integer
    
    belongs_to :company
  end
  
  @company_machine = StateMachine::Machine.new(@company, :initial => :active)
  @vehicle_machine = StateMachine::Machine.new(@vehicle, :initial => :parked)
  @vehicle_machine.state :idling
  
  @ford = @company.create
  @mustang = @vehicle.create(:company => @ford)
end
test_should_find_records_in_with_scope() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1917
def test_should_find_records_in_with_scope
  assert_equal [@mustang], @vehicle.with_states(:parked).all(Vehicle.company.state => 'active')
end
test_should_find_records_in_without_scope() click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 1921
def test_should_find_records_in_without_scope
  assert_equal [@mustang], @vehicle.without_states(:idling).all(Vehicle.company.state => 'active')
end