Sha256: cdd657bf3005e4b15240ab7806143082b13269eeccca98bbbcd6e2cd3c38ec50

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe AridCache do
  describe 'results' do
    before :each do
      Company.destroy_all
      @company1 = Company.make(:name => 'a')
      @company2 = Company.make(:name => 'b')
      Company.class_caches do
        ordered_by_name { Company.all(:order => 'name ASC') }
      end
      Company.clear_caches
    end

    it "order should match the original order" do
      3.times do |t|
        results = Company.cached_ordered_by_name
        results.size.should == 2
        results[0].name.should == @company1.name
        results[1].name.should == @company2.name
      end
    end

    it "order should match the order option" do
      3.times do |t|
        results = Company.cached_ordered_by_name(:order => 'name DESC')
        results.size.should == 2
        results[0].name.should == @company2.name
        results[1].name.should == @company1.name
      end
    end

    it "with order option should go to the database to order" do
      lambda {
        Company.cached_ordered_by_name(:order => 'name DESC').inspect
      }.should query(2)
    end
  end

  it "should set the special raw flag" do
    AridCache.raw_with_options.should be_false
    AridCache.raw_with_options = true
    AridCache.raw_with_options.should be_true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arid_cache-1.4.0 spec/arid_cache/arid_cache_spec.rb