replidog 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a4b8c94b670b9c069273bc80895906c77e45b19
4
- data.tar.gz: 23a1fe6a6f5046c4ecbcdfae731ec231f54a9d7a
3
+ metadata.gz: 46db50a29d4f79490ab194e8fd6ca7a93f35ef18
4
+ data.tar.gz: 0d07db46f99b14deef971a9f432f94c7df120973
5
5
  SHA512:
6
- metadata.gz: 5a5957e31918b7ddb0407fdc176ac42491b21edd933efed2e9eb77fb93fb91c9b1613e4dfb5617aa86a2159a24d368a3304eea783bc54d8243954621de482b43
7
- data.tar.gz: 595a8dda1bb18ec0e89bcd984307a573164c6252b75e7dc08c84f55d3c65301a183b6f242e711b42a0eac834c776150d467414b9a0406dabd99d4b683e7bc698
6
+ metadata.gz: 16e48177f5d08a6b3e10ee85786b68316ccb6e9ab95eb156246dbee8f3f3f6d1e8d442e9b1f7981c59d0f34ec929783905277139ad32cbd2a8bf1e94ad5542b2
7
+ data.tar.gz: 657b50e89491b0472cf0e28078dc760064e351fd03037198a00e2e4dd5cfe565f2ddec76a47c6795ba3ee211affe77119414623761f0a6a4dbc3bd2f6a7fdfa9
data/.gitignore CHANGED
@@ -14,3 +14,6 @@
14
14
  *.a
15
15
  gemfiles/*.gemfile.lock
16
16
  mkmf.log
17
+
18
+ # RubyMine Setting file.
19
+ .idea/
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.1.3
2
+ - Fix locking
3
+
1
4
  ## 1.1.2
2
5
  - Support Rails 5.1
3
6
 
data/README.md CHANGED
@@ -9,7 +9,7 @@ Based on https://github.com/r7kamura/replicat
9
9
  * Multiple master/slave
10
10
  * Auto switching between master/slave
11
11
  * Supports connection management and query cache
12
- * Supports Rails 3.2, 4.0, 4,1, 4.2, 5.0
12
+ * Supports Rails 3.2, 4.0, 4,1, 4.2, 5.0, 5.1
13
13
 
14
14
  ## Installation
15
15
 
@@ -54,7 +54,7 @@ module Replidog
54
54
  end
55
55
 
56
56
  module InstanceMethodsWithReplidogSupport
57
- def lock!
57
+ def lock!(lock = true)
58
58
  old_connection_name = self.class.connection.current_connection_name
59
59
  self.class.connection.current_connection_name ||= :master
60
60
  super
@@ -1,3 +1,3 @@
1
1
  module Replidog
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -304,4 +304,25 @@ describe Replidog::Model do
304
304
  end
305
305
  end
306
306
  end
307
+
308
+ describe "#with_lock" do
309
+ context "with using master name" do
310
+ it "executes SQL query on master connection" do
311
+ Recipe.using(:master).create(title: "test")
312
+ Recipe.using(:master).first.with_lock do
313
+ Recipe.first.update_attributes!(title: "test_update")
314
+ end
315
+ expect(Recipe.first).to eq Recipe.first
316
+ end
317
+ end
318
+
319
+ context "with using slave name" do
320
+ it "executes SQL query on slave connection" do
321
+ Recipe.using(:slave1).create(title: "test")
322
+ Recipe.using(:slave2).create(title: "test")
323
+ Recipe.using(:slave3).create(title: "test")
324
+ expect{ Recipe.first.with_lock }.to raise_error(ActiveRecord::RecordNotFound)
325
+ end
326
+ end
327
+ end
307
328
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: replidog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Ejima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-25 00:00:00.000000000 Z
11
+ date: 2018-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord