Sha256: 10702c6ebc930537764291dd089ace318329aacffa01e6ed28caf914cf633dc5

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

module Bullet
  module Detector
    describe Association do
      before :all do
        @post1 = Post.first
        @post2 = Post.last
      end
      before(:each) { Association.clear }

      context ".start_request" do
        it "should set @@checked to false" do
          Association.start_request
          Association.class_variable_get(:@@checked).should be_false
        end
      end

      context ".clear" do
        it "should clear all class variables" do
          Association.clear
          Association.class_variable_get(:@@object_associations).should be_nil
          Association.class_variable_get(:@@possible_objects).should be_nil
          Association.class_variable_get(:@@impossible_objects).should be_nil
          Association.class_variable_get(:@@call_object_associations).should be_nil
          Association.class_variable_get(:@@eager_loadings).should be_nil
        end
      end

      context ".add_object_association" do
        it "should add object, associations pair" do
          Association.add_object_associations(@post1, :associations)
          Association.send(:object_associations).should be_include(@post1.bullet_ar_key, :associations)
        end
      end

      context ".add_call_object_associations" do
        it "should add call object, associations pair" do
          Association.add_call_object_associations(@post1, :associations)
          Association.send(:call_object_associations).should be_include(@post1.bullet_ar_key, :associations)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bullet-4.7.1 spec/bullet/detector/association_spec.rb
bullet-4.7.0 spec/bullet/detector/association_spec.rb
bullet-4.6.0 spec/bullet/detector/association_spec.rb
bullet-4.5.0 spec/bullet/detector/association_spec.rb