class SequelTest::MachineWithScopesAndJoinsTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/sequel_test.rb, line 1497 def setup @company = new_model(:company) SequelTest.const_set('Company', @company) @vehicle = new_model(:vehicle) do many_to_one :company, :class => SequelTest::Company end DB.alter_table :vehicle do add_column :company_id, :integer end @vehicle.class_eval { get_db_schema(true) } SequelTest.const_set('Vehicle', @vehicle) @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
teardown()
click to toggle source
# File test/unit/integrations/sequel_test.rb, line 1526 def teardown SequelTest.class_eval do remove_const('Vehicle') remove_const('Company') end end
test_should_find_records_in_with_scope()
click to toggle source
# File test/unit/integrations/sequel_test.rb, line 1518 def test_should_find_records_in_with_scope assert_equal [@mustang], @vehicle.with_states(:parked).join(:company, :id => :company_id).filter(:company__state => 'active').select(:vehicle.*).all end
test_should_find_records_in_without_scope()
click to toggle source
# File test/unit/integrations/sequel_test.rb, line 1522 def test_should_find_records_in_without_scope assert_equal [@mustang], @vehicle.without_states(:idling).join(:company, :id => :company_id).filter(:company__state => 'active').select(:vehicle.*).all end