ar-octopus 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -37,7 +37,7 @@ begin
37
37
  gem.add_development_dependency "jeweler", ">= 1.4"
38
38
  gem.add_development_dependency "actionpack", ">= 2.3"
39
39
  gem.add_dependency('activerecord', '>= 2.3')
40
- gem.version = "0.2.2"
40
+ gem.version = "0.3.0"
41
41
  end
42
42
  Jeweler::GemcutterTasks.new
43
43
  rescue LoadError
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ar-octopus}
8
- s.version = "0.2.2"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Thiago Pradi", "Mike Perham"]
12
- s.date = %q{2010-11-03}
12
+ s.date = %q{2010-11-08}
13
13
  s.description = %q{This gem allows you to use sharded databases with ActiveRecord. this also provides a interface for replication and for running migrations with multiples shards.}
14
14
  s.email = %q{tchandy@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -160,7 +160,7 @@ class Octopus::Proxy
160
160
  end
161
161
 
162
162
  def should_send_queries_to_replicated_databases?(method)
163
- @replicated && method.to_s =~ /select/
163
+ @replicated && method.to_s =~ /select/ && !@block
164
164
  end
165
165
 
166
166
  def send_queries_to_selected_slave(method, *args, &block)
@@ -5,6 +5,14 @@ describe Octopus::Model do
5
5
  it "should return self after calling the #using method" do
6
6
  User.using(:canada).should == Octopus::ScopeProxy.new(:canada, User)
7
7
  end
8
+
9
+ it "should allow to send a block to the master shard" do
10
+ Octopus.using(:master) do
11
+ User.create!(:name => "Block test")
12
+ end
13
+
14
+ User.using(:master).find_by_name("Block test").should_not be_nil
15
+ end
8
16
 
9
17
  it "should allow selecting the shards on scope" do
10
18
  User.using(:canada).create!(:name => 'oi')
@@ -25,6 +25,14 @@ describe "when the database is replicated" do
25
25
  Cat.find_by_name("Slave Cat 2").should be_nil
26
26
  end
27
27
  end
28
+
29
+ it "should allow #using syntax to send queries to master" do
30
+ Cat.create!(:name => "Master Cat")
31
+
32
+ using_enviroment :production_fully_replicated do
33
+ Cat.using(:master).find_by_name("Master Cat").should_not be_nil
34
+ end
35
+ end
28
36
 
29
37
  it "should send the count query to a slave" do
30
38
  pending()
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 2
10
- version: 0.2.2
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Thiago Pradi
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-03 00:00:00 -02:00
19
+ date: 2010-11-08 00:00:00 -02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency