activerecord-multi-tenant 0.3.3 → 0.3.4

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: 25c5b203849744f6ee1d8e887164bf90c618c9d8
4
- data.tar.gz: 0351f5f55fb6aa5c6bfdfde9f5016b4da9221d87
3
+ metadata.gz: 261f0a075c9a14524dfc43455a030e710bd140a1
4
+ data.tar.gz: 3bdd3d5ef7aec6fa07d67a8226a600accb3eeadd
5
5
  SHA512:
6
- metadata.gz: 413b78faedc7d7f8514f4cfa5de2a50df0d75b38be90db3137da5ffad438453bf2d7404660ac378eeb307c3a9ae9559bae4961fff8e7c7ba723f300a5426094f
7
- data.tar.gz: 7acfcfbb62d2e1771c10168f0ff68a756bed4af5068c05d0a757bc4fb0c3ab8fc48944c0dd07393abc5691dc155ee5548a24d5e47ef731d411e45feeb4fed185
6
+ metadata.gz: 2b2c5621e0de6308ebc36169873318fd4975e7b54ae7e409a05d58978f65407e8ef6e99e82e2f7399dafdfb659421123cb849e825b93426c28e742ea4ff434a8
7
+ data.tar.gz: 0ced6530c9654b4dcfc4d326d6c97a1225d4a47b2300221a8b2fbf05ec3243fc27af128b9da975c73053d23235c333ff79fd10aaf378f7c0f3fb0c844395b4f0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.4 2017-02-22
4
+
5
+ * Expand with_lock workaround to cover lock! as well
6
+ * Enable trigger workaround on Rails 5 as well, otherwise it fails silently
7
+ * Tests: Switch to database cleaner truncation strategy to avoid multi-shard transactions
8
+
9
+
3
10
  ## 0.3.3 2017-02-21
4
11
 
5
12
  * Avoid warning about multi-column primary keys with Rails 5 [#2](https://github.com/citusdata/activerecord-multi-tenant/issues/2)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-multi-tenant (0.3.3)
4
+ activerecord-multi-tenant (0.3.4)
5
5
  rails (>= 3.1)
6
6
  request_store (>= 1.0.5)
7
7
 
@@ -150,4 +150,4 @@ DEPENDENCIES
150
150
  thor
151
151
 
152
152
  BUNDLED WITH
153
- 1.11.2
153
+ 1.13.6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- activerecord-multi-tenant (0.3.2)
4
+ activerecord-multi-tenant (0.3.4)
5
5
  rails (>= 3.1)
6
6
  request_store (>= 1.0.5)
7
7
 
@@ -133,4 +133,4 @@ DEPENDENCIES
133
133
  thor
134
134
 
135
135
  BUNDLED WITH
136
- 1.11.2
136
+ 1.13.6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- activerecord-multi-tenant (0.3.2)
4
+ activerecord-multi-tenant (0.3.4)
5
5
  rails (>= 3.1)
6
6
  request_store (>= 1.0.5)
7
7
 
@@ -116,4 +116,4 @@ DEPENDENCIES
116
116
  thor
117
117
 
118
118
  BUNDLED WITH
119
- 1.11.2
119
+ 1.13.6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- activerecord-multi-tenant (0.3.2)
4
+ activerecord-multi-tenant (0.3.4)
5
5
  rails (>= 3.1)
6
6
  request_store (>= 1.0.5)
7
7
 
@@ -121,4 +121,4 @@ DEPENDENCIES
121
121
  thor
122
122
 
123
123
  BUNDLED WITH
124
- 1.11.2
124
+ 1.13.6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- activerecord-multi-tenant (0.3.2)
4
+ activerecord-multi-tenant (0.3.4)
5
5
  rails (>= 3.1)
6
6
  request_store (>= 1.0.5)
7
7
 
@@ -144,4 +144,4 @@ DEPENDENCIES
144
144
  thor
145
145
 
146
146
  BUNDLED WITH
147
- 1.11.2
147
+ 1.13.6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- activerecord-multi-tenant (0.3.2)
4
+ activerecord-multi-tenant (0.3.4)
5
5
  rails (>= 3.1)
6
6
  request_store (>= 1.0.5)
7
7
 
@@ -151,4 +151,4 @@ DEPENDENCIES
151
151
  thor
152
152
 
153
153
  BUNDLED WITH
154
- 1.11.2
154
+ 1.13.6
@@ -1,15 +1,13 @@
1
1
  # Workaround for https://github.com/citusdata/citus/issues/1080
2
2
  # "Support DISABLE/ENABLE TRIGGER ALL on distributed tables"
3
3
 
4
- if Rails::VERSION::MAJOR < 5
5
- require 'active_record/connection_adapters/postgresql_adapter'
4
+ require 'active_record/connection_adapters/postgresql_adapter'
6
5
 
7
- module ActiveRecord
8
- module ConnectionAdapters
9
- class PostgreSQLAdapter < AbstractAdapter
10
- def supports_disable_referential_integrity?
11
- false
12
- end
6
+ module ActiveRecord
7
+ module ConnectionAdapters
8
+ class PostgreSQLAdapter < AbstractAdapter
9
+ def supports_disable_referential_integrity?
10
+ false
13
11
  end
14
12
  end
15
13
  end
@@ -1,3 +1,3 @@
1
1
  module MultiTenant
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
@@ -2,16 +2,14 @@
2
2
  # "SELECT ... FOR UPDATE is not supported for router-plannable queries"
3
3
 
4
4
  class ActiveRecord::Base
5
- alias :with_lock_orig :with_lock
6
- def with_lock(&block)
7
- if self.class.respond_to?(:scoped_by_tenant?) && MultiTenant.current_tenant_id && MultiTenant.with_lock_workaround_enabled?
8
- transaction do
9
- self.class.unscoped.where(id: id).update_all(id: id) # No-op UPDATE that locks the row
10
- reload # This is just to act similar to the default Rails approach, in case someone relies on the reload
11
- yield
12
- end
5
+ alias :lock_orig :lock!
6
+ def lock!(lock = true)
7
+ if lock && persisted? && self.class.respond_to?(:scoped_by_tenant?) && MultiTenant.current_tenant_id && MultiTenant.with_lock_workaround_enabled?
8
+ self.class.unscoped.where(id: id).update_all(id: id) # No-op UPDATE that locks the row
9
+ reload # This is just to act similar to the default Rails approach, in case someone relies on the reload
10
+ self
13
11
  else
14
- with_lock_orig(&block)
12
+ lock_orig(lock)
15
13
  end
16
14
  end
17
15
  end
@@ -159,7 +159,7 @@ describe MultiTenant do
159
159
  expect(MultiTenant.current_tenant).to eq(@account1)
160
160
  end
161
161
 
162
- it "should return the value of the block", pending: 'There is currently an ordering issue that causes this test to fail without good reason' do
162
+ it "should return the value of the block" do
163
163
  @account1 = Account.create!(:name => 'foo')
164
164
  @account2 = Account.create!(:name => 'bar')
165
165
 
data/spec/spec_helper.rb CHANGED
@@ -21,8 +21,8 @@ RSpec.configure do |config|
21
21
  end
22
22
 
23
23
  config.before(:suite) do
24
- DatabaseCleaner[:active_record].strategy = :transaction
25
- DatabaseCleaner[:active_record].clean_with(:truncation)
24
+ DatabaseCleaner[:active_record].strategy = :truncation
25
+ DatabaseCleaner[:active_record].clean
26
26
 
27
27
  # Keep this here until https://github.com/citusdata/citus/issues/1236 is fixed in a patch release we can run tests with
28
28
  MultiTenant.enable_with_lock_workaround
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-multi-tenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Citus Data