mongoid-multitenancy 2.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/lib/mongoid/multitenancy.rb +7 -5
- data/lib/mongoid/multitenancy/version.rb +1 -1
- data/spec/mongoid-multitenancy_spec.rb +9 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c38ddec7cbb763f8fe21c663051a825ac342e325
|
4
|
+
data.tar.gz: 6566d061de75d4b9cf092ef1864b35c0e061ffc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7844d83386cdea3bfdcb7eddf5a91cdb85e346530d91de291eacc07d767fda5a04ec0baec47a44171459a69c0ebf91d516b4cff751b4bc026c36baa54f49e26
|
7
|
+
data.tar.gz: 1fa4b30f02ac4ae4c51a93f8cf0af9f6bf209059cc9b05b179c011da3fd507b463d416255660d09891e3c141d92fa1a7434261e164c6f0d311c159eec163610a
|
data/Gemfile
CHANGED
@@ -2,13 +2,13 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gem 'mongoid', '~> 6.0'
|
4
4
|
|
5
|
-
gem 'rake'
|
5
|
+
gem 'rake'
|
6
6
|
|
7
7
|
group :test do
|
8
8
|
gem 'database_cleaner'
|
9
9
|
gem 'coveralls', require: false
|
10
10
|
gem 'rspec', '~> 3.1'
|
11
|
-
gem 'yard'
|
11
|
+
gem 'yard'
|
12
12
|
gem 'mongoid-rspec', git: 'https://github.com/mongoid-rspec/mongoid-rspec.git'
|
13
13
|
gem 'rubocop', require: false
|
14
14
|
end
|
data/lib/mongoid/multitenancy.rb
CHANGED
@@ -21,11 +21,13 @@ module Mongoid
|
|
21
21
|
def with_tenant(tenant, &block)
|
22
22
|
raise ArgumentError, 'block required' if block.nil?
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
begin
|
25
|
+
old_tenant = current_tenant
|
26
|
+
self.current_tenant = tenant
|
27
|
+
yield
|
28
|
+
ensure
|
29
|
+
self.current_tenant = old_tenant
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -24,5 +24,14 @@ describe Mongoid::Multitenancy do
|
|
24
24
|
Mongoid::Multitenancy.with_tenant(another_client) { ; }
|
25
25
|
expect(Mongoid::Multitenancy.current_tenant).to eq client
|
26
26
|
end
|
27
|
+
|
28
|
+
context 'when the block fails' do
|
29
|
+
it 'restores the current tenant' do
|
30
|
+
begin
|
31
|
+
Mongoid::Multitenancy.with_tenant(another_client) { raise StandardError }
|
32
|
+
rescue StandardError; end
|
33
|
+
expect(Mongoid::Multitenancy.current_tenant).to eq client
|
34
|
+
end
|
35
|
+
end
|
27
36
|
end
|
28
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-multitenancy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aymeric Brisse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.6.
|
91
|
+
rubygems_version: 2.6.13
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: Support of a multi-tenant database with Mongoid
|