spec/octopus/migration_spec.rb in ar-octopus-0.0.23 vs spec/octopus/migration_spec.rb in ar-octopus-0.0.24

- old
+ new

@@ -44,9 +44,18 @@ User.using(:brazil).find(:all, :conditions => {:name => "UsingBlock2"}).size.should == 1 User.using(:canada).find(:all, :conditions => {:name => "UsingCanada"}).size.should == 1 User.using(:canada).find(:all, :conditions => {:name => "UsingCanada2"}).size.should == 1 end end + + it "should send the query to the correct shard" do + migrating_to_version 13 do + User.using(:brazil).find(:all, :conditions => {:name => "Brazil"}).size.should == 1 + User.using(:brazil).find(:all, :conditions => {:name => "Canada"}).size.should == 0 + User.using(:canada).find(:all, :conditions => {:name => "Brazil"}).size.should == 0 + User.using(:canada).find(:all, :conditions => {:name => "Canada"}).size.should == 1 + end + end describe "should raise a exception when" do it "you specify a invalid shard name" do lambda { ActiveRecord::Migrator.run(:up, MIGRATIONS_ROOT, 6) }.should raise_error("Nonexistent Shard Name: amazing_shard") end