Sha256: 2c73774bad17e8de0efd2488bcac5782add11f00a6c736142d2a049b4006174e

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

if active_record3?
  describe Bullet::Detector::Counter do
    before(:each) do
      Bullet.start_request
    end

    after(:each) do
      Bullet.end_request
    end

    it "should need counter cache with all cities" do
      Country.all.each do |country|
        country.cities.size
      end
      Bullet.collected_counter_cache_notifications.should_not be_empty
    end

    it "should not need counter cache if already define counter_cache" do
      Person.all.each do |person|
        person.pets.size
      end
      Bullet.collected_counter_cache_notifications.should be_empty
    end

    it "should not need counter cache with only one object" do
      Country.first.cities.size
      Bullet.collected_counter_cache_notifications.should be_empty
    end

    it "should not need counter cache with part of cities" do
      Country.all.each do |country|
        country.cities.where(:name => 'first').size
      end
      Bullet.collected_counter_cache_notifications.should be_empty
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bullet-4.3.1 spec/integration/counter_spec.rb
bullet-4.3.0 spec/integration/counter_spec.rb
bullet-4.2.0 spec/integration/counter_spec.rb
bullet-4.1.6 spec/integration/counter_spec.rb
bullet-4.1.5 spec/integration/counter_spec.rb
bullet-4.1.4 spec/integration/counter_spec.rb
bullet-4.1.3 spec/integration/counter_spec.rb
bullet-4.1.2 spec/integration/counter_spec.rb
bullet-4.1.1 spec/integration/counter_spec.rb