class MongoidTest::MachineWithScopesAndOwnerSubclassTest
Public Class Methods
name()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1436 def self.name 'MongoidTest::SubFoo' end
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1429 def setup @model = new_model @machine = StateMachine::Machine.new(@model, :state) MongoidTest.const_set('Foo', @model) @subclass = Class.new(@model) do def self.name 'MongoidTest::SubFoo' end end @subclass_machine = @subclass.state_machine(:state) {} @subclass_machine.state :parked, :idling, :first_gear MongoidTest.const_set('SubFoo', @subclass) end
teardown()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1461 def teardown MongoidTest.send(:remove_const, 'SubFoo') MongoidTest.send(:remove_const, 'Foo') end
test_should_only_include_records_with_subclass_states_in_with_scope()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1446 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).to_a end
test_should_only_include_records_without_subclass_states_in_without_scope()
click to toggle source
# File test/unit/integrations/mongoid_test.rb, line 1453 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).to_a end