class ActiveRecordTest::MachineWithScopesAndJoinsTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1909 def setup @company = new_model(:company) ActiveRecordTest.const_set('Company', @company) @vehicle = new_model(:vehicle) do connection.add_column :vehicle, :company_id, :integer belongs_to :company, :class_name => 'ActiveRecordTest::Company' end ActiveRecordTest.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/active_record_test.rb, line 1935 def teardown ActiveRecordTest.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/active_record_test.rb, line 1927 def test_should_find_records_in_with_scope assert_equal [@mustang], @vehicle.with_states(:parked).find(:all, :include => :company, :conditions => 'company.state = "active"') end
test_should_find_records_in_without_scope()
click to toggle source
# File test/unit/integrations/active_record_test.rb, line 1931 def test_should_find_records_in_without_scope assert_equal [@mustang], @vehicle.without_states(:idling).find(:all, :include => :company, :conditions => 'company.state = "active"') end