class MongoidTest::MachineWithScopesTest

Public Instance Methods

setup() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1361
def setup
  @model = new_model
  @machine = StateMachine::Machine.new(@model)
  @machine.state :parked, :first_gear
  @machine.state :idling, :value => lambda {'idling'}
end
test_should_allow_chaining_scopes() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1420
def test_should_allow_chaining_scopes
  parked = @model.create :state => 'parked'
  idling = @model.create :state => 'idling'
  
  assert_equal [idling], @model.without_state(:parked).with_state(:idling).all
end
test_should_allow_lookup_by_string_name() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1390
def test_should_allow_lookup_by_string_name
  parked = @model.create :state => 'parked'
  idling = @model.create :state => 'idling'
  
  assert_equal [parked, idling], @model.with_states('parked', 'idling').to_a
end
test_should_create_plural_with_scope() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1379
def test_should_create_plural_with_scope
  assert @model.respond_to?(:with_states)
end
test_should_create_plural_without_scope() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1408
def test_should_create_plural_without_scope
  assert @model.respond_to?(:without_states)
end
test_should_create_singular_with_scope() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1368
def test_should_create_singular_with_scope
  assert @model.respond_to?(:with_state)
end
test_should_create_singular_without_scope() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1397
def test_should_create_singular_without_scope
  assert @model.respond_to?(:without_state)
end
test_should_only_include_records_with_state_in_singular_with_scope() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1372
def test_should_only_include_records_with_state_in_singular_with_scope
  parked = @model.create :state => 'parked'
  idling = @model.create :state => 'idling'
  
  assert_equal [parked], @model.with_state(:parked).to_a
end
test_should_only_include_records_with_states_in_plural_with_scope() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1383
def test_should_only_include_records_with_states_in_plural_with_scope
  parked = @model.create :state => 'parked'
  idling = @model.create :state => 'idling'
  
  assert_equal [parked, idling], @model.with_states(:parked, :idling).to_a
end
test_should_only_include_records_without_state_in_singular_without_scope() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1401
def test_should_only_include_records_without_state_in_singular_without_scope
  parked = @model.create :state => 'parked'
  idling = @model.create :state => 'idling'
  
  assert_equal [parked], @model.without_state(:idling).to_a
end
test_should_only_include_records_without_states_in_plural_without_scope() click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1412
def test_should_only_include_records_without_states_in_plural_without_scope
  parked = @model.create :state => 'parked'
  idling = @model.create :state => 'idling'
  first_gear = @model.create :state => 'first_gear'
  
  assert_equal [parked, idling], @model.without_states(:first_gear).to_a
end