Sha256: 84d4b3a717160434226fb98e9d37c7ddbc7955a030114c3ff2e4775208e15e90

Contents?: true

Size: 1022 Bytes

Versions: 6

Compression:

Stored size: 1022 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Octopus::ScopeProxy do
  it "should allow nested queries" do
    if Octopus.rails3?
      @user1 = User.using(:brazil).create!(:name => "Thiago P", :number => 3)
      @user2 = User.using(:brazil).create!(:name => "Thiago", :number => 1)
      @user3 = User.using(:brazil).create!(:name => "Thiago", :number => 2)
    
      User.using(:brazil).where(:name => "Thiago").where(:number => 4).order(:number).all.should == []
      User.using(:brazil).where(:name => "Thiago").using(:canada).where(:number => 2).using(:brazil).order(:number).all.should == [@user3]
      User.using(:brazil).where(:name => "Thiago").using(:canada).where(:number => 4).using(:brazil).order(:number).all.should == []
    end
  end
  
  it "should raise a exception when trying to send a query to a shard that don't exists" do
    lambda { User.where(:name => "Thiago").using(:dont_exists).all }.should raise_exception("Nonexistent Shard Name: dont_exists")
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ar-octopus-0.3.3 spec/octopus/scope_proxy_spec.rb
ar-octopus-0.3.2 spec/octopus/scope_proxy_spec.rb
ar-octopus-0.3.1 spec/octopus/scope_proxy_spec.rb
ar-octopus-0.3.0 spec/octopus/scope_proxy_spec.rb
ar-octopus-0.2.2 spec/octopus/scope_proxy_spec.rb
ar-octopus-0.2.1 spec/octopus/scope_proxy_spec.rb