Sha256: 1695422920b6fb644de9cd770c0fac34a98853e9102d0710d496816e3b56055c

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'
describe ConnectionManager::Shards do
  before(:each) do
    Fruit.shard_class_names("SouthernFruit")            
  end
  context 'shards'do    
    it "should return an array of results" do
      a = Fruit.shards do |shard|
        shard.first
      end
      a.should be_a_kind_of(Array)
    end
    
    it "should execute the active record methods on the the provided models" do
      fruit = FactoryGirl.create(:fruit)
      klasses = ["Fruit","SouthernFruit"]
      a = Fruit.shards do |shard|
        shard.where(:id => fruit.id).first
      end
      klasses.include?(a[0].class.name).should be_true
    end
   
      
    it "should not matter how the where statement is formated" do
      fruit = FactoryGirl.create(:fruit)
      a = Fruit.shards do |shard|
        shard.where(:id => fruit.id).first
      end
      b = Fruit.shards do |shard|
        shard.where(['id = ?', fruit.id]).first
      end
        
      c = Fruit.shards do |shard|
        shard.where('id = ?', fruit.id).first    
      end
        
      (a == b && b == c).should be_true
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
connection_manager-0.3.11 spec/lib/shards_spec.rb
connection_manager-0.3.10 spec/lib/shards_spec.rb
connection_manager-0.3.9 spec/lib/shards_spec.rb
connection_manager-0.3.8 spec/lib/shards_spec.rb
connection_manager-0.3.7 spec/lib/shards_spec.rb
connection_manager-0.3.6 spec/lib/shards_spec.rb
connection_manager-0.3.5 spec/lib/shards_spec.rb
connection_manager-0.3.4 spec/lib/shards_spec.rb
connection_manager-0.3.3 spec/lib/shards_spec.rb
connection_manager-0.3.2 spec/lib/shards_spec.rb
connection_manager-0.3.1 spec/lib/shards_spec.rb
connection_manager-0.3.0 spec/lib/shards_spec.rb