mongoid-multitenancy 2.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 431219928a15faa3df3004d3b81b840bc8650691
4
- data.tar.gz: 41c7101a950c1ae7539912038befff3c9e4cac63
3
+ metadata.gz: c38ddec7cbb763f8fe21c663051a825ac342e325
4
+ data.tar.gz: 6566d061de75d4b9cf092ef1864b35c0e061ffc8
5
5
  SHA512:
6
- metadata.gz: 6c7e4c5902e9da5050c1bf14797a93d06a1303fa61fed4ad9cb6b32ea57309f6abbe8ecef530f37457e9474fc18bd2eeb99812229c67abbaf9e8a7b3cceec1fe
7
- data.tar.gz: 14df29dad2f6946275bbc152823003a04c701b44f3bac4774fdbbf11faabe7d4d5aad0b1f49b7f544d298c7ef6d0ed056874fe8a26c047b09de7986ddc1c13b6
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', '~> 11.0'
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', '~> 0.8'
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
@@ -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
- old_tenant = current_tenant
25
- self.current_tenant = tenant
26
- result = yield
27
- self.current_tenant = old_tenant
28
- result
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
@@ -1,6 +1,6 @@
1
1
  module Mongoid
2
2
  module Multitenancy
3
3
  # Version
4
- VERSION = '2.0'.freeze
4
+ VERSION = '2.0.1'.freeze
5
5
  end
6
6
  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: '2.0'
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-07-21 00:00:00.000000000 Z
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.11
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