Sha256: 9aa4e82bbd928068161f3eb96ff4111f7d200c9d4fed9eef797e2b36ef060e50

Contents?: true

Size: 1.57 KB

Versions: 43

Compression:

Stored size: 1.57 KB

Contents

# Some test models
# These will get created and dropped during the active record tests
# Be sure and call setup and teardown
module ActiveRecordFixtures
  extend self
  def setup
    ActiveRecordFixtures::Order.setup
    ActiveRecordFixtures::Shipment.setup
  end
  def teardown
    ActiveRecordFixtures::Shipment.teardown
    ActiveRecordFixtures::Order.teardown
  end
  class Order < ActiveRecord::Base
    self.table_name = 'newrelic_test_orders'
    has_and_belongs_to_many :shipments, :class_name => 'ActiveRecordFixtures::Shipment'
    def self.setup
      connection.create_table self.table_name, :force => true do |t|
        t.column :name, :string
      end
    end
    def self.add_delay
      # Introduce a 500 ms delay into db operations on Orders
      def connection.log_info *args
        sleep 0.5
        super *args
      end
    end
    def self.teardown
      connection.drop_table table_name
      def connection.log_info *args
        super *args
      end
    end
  end
  
  class Shipment < ActiveRecord::Base
    self.table_name = 'newrelic_test_shipment'
    has_and_belongs_to_many :orders, :class_name => 'ActiveRecordFixtures::Order'
    def self.setup
      connection.create_table self.table_name, :force => true do |t|
        # no other columns
      end
      connection.create_table 'orders_shipments', :force => true, :id => false do |t|
        t.column :order_id, :integer 
        t.column :shipment_id, :integer 
      end
    end
    
    def self.teardown
      connection.drop_table 'orders_shipments'
      connection.drop_table self.table_name
    end
  end    
end

Version data entries

43 entries across 43 versions & 4 rubygems

Version Path
newrelic_rpm-2.13.4.rum6 test/active_record_fixtures.rb
newrelic_rpm-2.14.0 test/active_record_fixtures.rb
newrelic_rpm-2.13.4.rum5 test/active_record_fixtures.rb
newrelic_rpm-2.13.6.beta2 test/active_record_fixtures.rb
newrelic_rpm-2.13.6.beta1 test/active_record_fixtures.rb
newrelic_rpm-2.13.4.rum4 test/active_record_fixtures.rb
newrelic_rpm-2.13.5.beta4 test/active_record_fixtures.rb
newrelic_rpm-2.13.5.beta3 test/active_record_fixtures.rb
newrelic_rpm-2.13.5.beta2 test/active_record_fixtures.rb
newrelic_rpm-2.13.5.beta1 test/active_record_fixtures.rb
newrelic_rpm-2.13.4.eum3 test/active_record_fixtures.rb
newrelic_rpm-2.13.4.eum2 test/active_record_fixtures.rb
newrelic_rpm-2.13.4.eum1 test/active_record_fixtures.rb
newrelic_rpm-2.13.4 test/active_record_fixtures.rb
newrelic_rpm-2.13.3 test/active_record_fixtures.rb
newrelic_rpm-2.13.3.beta test/active_record_fixtures.rb
newrelic_rpm-2.13.2 test/active_record_fixtures.rb
honkster-newrelic_rpm-2.13.1 test/active_record_fixtures.rb
onyx_newrelic_rpm-2.12.5 test/active_record_fixtures.rb
newrelic_rpm-2.13.1 test/active_record_fixtures.rb