mongoid-multitenancy 1.1.3 → 1.2.0
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 +4 -4
- data/Gemfile +3 -3
- data/README.md +29 -9
- data/gemfiles/Gemfile.mongoid-4.0 +4 -3
- data/gemfiles/Gemfile.mongoid-5.0 +5 -4
- data/lib/mongoid/multitenancy/document.rb +8 -5
- data/lib/mongoid/multitenancy/validators/tenancy.rb +4 -4
- data/lib/mongoid/multitenancy/validators/tenant_uniqueness.rb +2 -2
- data/lib/mongoid/multitenancy/version.rb +1 -1
- data/lib/mongoid/multitenancy.rb +2 -3
- data/mongoid-multitenancy.gemspec +2 -2
- data/spec/indexable_spec.rb +4 -6
- data/spec/mandatory_spec.rb +12 -1
- data/spec/models/account.rb +1 -1
- data/spec/models/immutable.rb +3 -3
- data/spec/models/indexable.rb +1 -1
- data/spec/models/mandatory.rb +2 -2
- data/spec/models/mutable.rb +3 -3
- data/spec/models/mutable_child.rb +3 -3
- data/spec/models/no_scopable.rb +11 -0
- data/spec/models/optional.rb +1 -1
- data/spec/models/optional_exclude.rb +15 -0
- data/spec/mongoid-multitenancy_spec.rb +1 -1
- data/spec/mutable_child_spec.rb +0 -1
- data/spec/optional_exclude_spec.rb +71 -0
- data/spec/optional_spec.rb +0 -1
- data/spec/scopable_spec.rb +29 -0
- data/spec/support/shared_examples.rb +0 -1
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc62ee7dad2407f285292511b1a3ff9487b2f658
|
4
|
+
data.tar.gz: de93ec4f6f8182bd4307c9cc865b585f215d9a68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bbfd25a05be1f5bb1a873fa53f42df8546b6cc24a568b846500d6b8e429df9ebb6781e21fdac50b91f34f95a415f0c8a83dd9de0017e0d86919828c215b13b2
|
7
|
+
data.tar.gz: 747a8e3b7e5cc1ee8daaa5713a3e39f82978a27c10e0dac8bc4b7ef94eb38b561c982c8349252a6265b2dee08fc0981a796ff9149776c02f080687f9479f6274
|
data/Gemfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'mongoid', '~> 5.
|
3
|
+
gem 'mongoid', '~> 5.1'
|
4
4
|
|
5
|
-
gem 'rake', '~>
|
5
|
+
gem 'rake', '~> 11.0'
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem 'database_cleaner'
|
8
|
+
gem 'database_cleaner'
|
9
9
|
gem 'coveralls', require: false
|
10
10
|
gem 'rspec', '~> 3.1'
|
11
11
|
gem 'yard', '~> 0.8'
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# mongoid-multitenancy [](https://travis-ci.org/PerfectMemory/mongoid-multitenancy) [](https://coveralls.io/github/PerfectMemory/mongoid-multitenancy?branch=master) [](https://codeclimate.com/github/PerfectMemory/mongoid-multitenancy) [](https://gemnasium.com/PerfectMemory/mongoid-multitenancy)
|
1
|
+
# mongoid-multitenancy [](https://travis-ci.org/PerfectMemory/mongoid-multitenancy) [](https://coveralls.io/github/PerfectMemory/mongoid-multitenancy?branch=master) [](https://codeclimate.com/github/PerfectMemory/mongoid-multitenancy) [](https://gemnasium.com/PerfectMemory/mongoid-multitenancy)
|
2
2
|
|
3
3
|
mongoid-multitenancy adds the ability to scope [Mongoid](https://github.com/mongoid/mongoid) models to a tenant in a **shared database strategy**. Tenants are represented by a tenant model, such as `Client`. mongoid-multitenancy will help you set the current tenant on each request and ensures that all 'tenant models' are always properly scoped to the current tenant: when viewing, searching and creating.
|
4
4
|
|
@@ -85,10 +85,14 @@ The association passed to the `tenant` function must be valid.
|
|
85
85
|
|
86
86
|
`tenant` accepts several options:
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
| Option | Default | Description |
|
89
|
+
| ------------- | ------------- | ------------- |
|
90
|
+
| :optional | false | set to true when the tenant is optional |
|
91
|
+
| :immutable | true | set to true when the tenant field is immutable |
|
92
|
+
| :full_indexes | true | set to true to add the tenant field automatically to all the indexes |
|
93
|
+
| :index | false | set to true to define an index for the tenant field |
|
94
|
+
| :scopes | true | set to true to define scopes :shared and :unshared |
|
95
|
+
| :class_name, etc. | | all the other options will be passed to the mongoid relation (belongs_to) |
|
92
96
|
|
93
97
|
Some examples to illustrate this behavior:
|
94
98
|
|
@@ -181,12 +185,12 @@ class Article
|
|
181
185
|
end
|
182
186
|
```
|
183
187
|
|
184
|
-
* When used with an *optional* tenant, the uniqueness constraint is not scoped if the item is shared, but is
|
185
|
-
scoped to the client new item otherwise. Note that a private item cannot have
|
186
|
-
already uses it.
|
188
|
+
* When used with an *optional* tenant, the uniqueness constraint by default is not scoped if the item is shared, but is
|
189
|
+
scoped to the client new item otherwise. Note that by default in that case a private item cannot have a value if a shared item
|
190
|
+
already uses it. You can change that behaviour by setting the option `exclude_shared` to `true`.
|
187
191
|
|
188
192
|
In the following case, 2 private articles can have the same slug if they belongs to 2 different clients. But if a shared
|
189
|
-
article has the slug "slugA", no client will be able to use that slug again, like a standard validates_uniqueness_of does.
|
193
|
+
article has the slug "slugA", no client will be able to use that slug again, like a standard `validates_uniqueness_of` does.
|
190
194
|
|
191
195
|
```ruby
|
192
196
|
class Article
|
@@ -201,6 +205,22 @@ class Article
|
|
201
205
|
end
|
202
206
|
```
|
203
207
|
|
208
|
+
In the following case, 2 private articles can have the same slug if they belongs to 2 different clients even if a shared
|
209
|
+
article already uses that same slug, like a `validates_uniqueness_of scope: :client` does.
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
class Article
|
213
|
+
include Mongoid::Document
|
214
|
+
include Mongoid::Multitenancy::Document
|
215
|
+
|
216
|
+
tenant :client, optional: true
|
217
|
+
|
218
|
+
field :slug
|
219
|
+
|
220
|
+
validates_tenant_uniqueness_of :slug, exclude_shared: true
|
221
|
+
end
|
222
|
+
```
|
223
|
+
|
204
224
|
Mongoid indexes
|
205
225
|
-------------------
|
206
226
|
|
@@ -2,14 +2,15 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gem 'mongoid', '~> 4.0'
|
4
4
|
|
5
|
-
gem 'rake', '~>
|
5
|
+
gem 'rake', '~> 11.0'
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem 'database_cleaner'
|
9
|
-
gem 'coveralls', :
|
8
|
+
gem 'database_cleaner'
|
9
|
+
gem 'coveralls', require: false
|
10
10
|
gem 'rspec', '~> 3.1'
|
11
11
|
gem 'yard', '~> 0.8'
|
12
12
|
gem 'mongoid-rspec', '~> 2.1'
|
13
|
+
gem 'rubocop', require: false
|
13
14
|
end
|
14
15
|
|
15
16
|
# Specify your gem's dependencies in mongoid-multitenancy.gemspec
|
@@ -1,15 +1,16 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'mongoid', '~> 5.
|
3
|
+
gem 'mongoid', '~> 5.1'
|
4
4
|
|
5
|
-
gem 'rake', '~>
|
5
|
+
gem 'rake', '~> 11.0'
|
6
6
|
|
7
7
|
group :test do
|
8
|
-
gem 'database_cleaner'
|
9
|
-
gem 'coveralls', :
|
8
|
+
gem 'database_cleaner'
|
9
|
+
gem 'coveralls', require: false
|
10
10
|
gem 'rspec', '~> 3.1'
|
11
11
|
gem 'yard', '~> 0.8'
|
12
12
|
gem 'mongoid-rspec', '~> 3.0'
|
13
|
+
gem 'rubocop', require: false
|
13
14
|
end
|
14
15
|
|
15
16
|
# Specify your gem's dependencies in mongoid-multitenancy.gemspec
|
@@ -7,7 +7,7 @@ module Mongoid
|
|
7
7
|
attr_accessor :tenant_field, :tenant_options
|
8
8
|
|
9
9
|
# List of authorized options
|
10
|
-
MULTITENANCY_OPTIONS = [:optional, :immutable, :full_indexes, :index]
|
10
|
+
MULTITENANCY_OPTIONS = [:optional, :immutable, :full_indexes, :index, :scopes].freeze
|
11
11
|
|
12
12
|
# Defines the tenant field for the document.
|
13
13
|
#
|
@@ -24,10 +24,13 @@ module Mongoid
|
|
24
24
|
# wil raise an Exception.
|
25
25
|
# @option options [ Boolean ] :optional If true allow the document
|
26
26
|
# to be shared among all the tenants.
|
27
|
-
#
|
27
|
+
# @option options [ Boolean ] :index If true build an index for
|
28
|
+
# the tenant field itself.
|
29
|
+
# @option options [ Boolean ] :scopes If true create scopes :shared
|
30
|
+
# and :unshared.
|
28
31
|
# @return [ Field ] The generated field
|
29
32
|
def tenant(association = :account, options = {})
|
30
|
-
options = { full_indexes: true, immutable: true }.merge!(options)
|
33
|
+
options = { full_indexes: true, immutable: true, scopes: true }.merge!(options)
|
31
34
|
assoc_options, multitenant_options = build_options(options)
|
32
35
|
|
33
36
|
# Setup the association between the class and the tenant class
|
@@ -40,7 +43,7 @@ module Mongoid
|
|
40
43
|
# Validates the tenant field
|
41
44
|
validates_tenancy_of tenant_field, multitenant_options
|
42
45
|
|
43
|
-
define_scopes
|
46
|
+
define_scopes if multitenant_options[:scopes]
|
44
47
|
define_initializer association
|
45
48
|
define_inherited association, options
|
46
49
|
define_index if multitenant_options[:index]
|
@@ -131,7 +134,7 @@ module Mongoid
|
|
131
134
|
# Define the inherited method
|
132
135
|
def define_inherited(association, options)
|
133
136
|
define_singleton_method(:inherited) do |child|
|
134
|
-
child.tenant association, options
|
137
|
+
child.tenant association, options.merge(scopes: false)
|
135
138
|
super(child)
|
136
139
|
end
|
137
140
|
end
|
@@ -16,18 +16,18 @@ module Mongoid
|
|
16
16
|
def validate_each(object, attribute, value)
|
17
17
|
# Immutable Check
|
18
18
|
if options[:immutable]
|
19
|
-
if object.send(:attribute_changed?, attribute)
|
19
|
+
if object.send(:attribute_changed?, attribute) && object.send(:attribute_was, attribute)
|
20
20
|
object.errors.add(attribute, 'is immutable and cannot be updated')
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
# Ownership check
|
25
|
-
if value
|
26
|
-
object.errors.add(attribute,
|
25
|
+
if value && Mongoid::Multitenancy.current_tenant && value != Mongoid::Multitenancy.current_tenant.id
|
26
|
+
object.errors.add(attribute, 'not authorized')
|
27
27
|
end
|
28
28
|
|
29
29
|
# Optional Check
|
30
|
-
if !options[:optional]
|
30
|
+
if !options[:optional] && value.nil?
|
31
31
|
object.errors.add(attribute, 'is mandatory')
|
32
32
|
end
|
33
33
|
end
|
@@ -58,8 +58,8 @@ module Mongoid
|
|
58
58
|
name = document.database_field_name(item)
|
59
59
|
tenant_value = document.attributes[name]
|
60
60
|
|
61
|
-
if document.class.tenant_options[:optional]
|
62
|
-
if
|
61
|
+
if document.class.tenant_options[:optional] && !options[:exclude_shared]
|
62
|
+
if tenant_value
|
63
63
|
criteria = criteria.where(:"#{item}".in => [tenant_value, nil])
|
64
64
|
end
|
65
65
|
else
|
data/lib/mongoid/multitenancy.rb
CHANGED
@@ -7,7 +7,6 @@ require 'mongoid/multitenancy/validators/tenant_uniqueness'
|
|
7
7
|
module Mongoid
|
8
8
|
module Multitenancy
|
9
9
|
class << self
|
10
|
-
|
11
10
|
# Set the current tenant. Make it Thread aware
|
12
11
|
def current_tenant=(tenant)
|
13
12
|
Thread.current[:current_tenant] = tenant
|
@@ -22,9 +21,9 @@ module Mongoid
|
|
22
21
|
def with_tenant(tenant, &block)
|
23
22
|
raise ArgumentError, 'block required' if block.nil?
|
24
23
|
|
25
|
-
old_tenant =
|
24
|
+
old_tenant = current_tenant
|
26
25
|
self.current_tenant = tenant
|
27
|
-
result =
|
26
|
+
result = yield
|
28
27
|
self.current_tenant = old_tenant
|
29
28
|
result
|
30
29
|
end
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.summary = 'Support of a multi-tenant database with Mongoid'
|
9
9
|
gem.homepage = 'https://github.com/PerfectMemory/mongoid-multitenancy'
|
10
10
|
gem.license = 'MIT'
|
11
|
-
gem.files = `git ls-files`.split(
|
12
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
11
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.name = 'mongoid-multitenancy'
|
15
15
|
gem.require_paths = ['lib']
|
data/spec/indexable_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'tenant' do
|
4
|
-
|
5
4
|
let(:client) do
|
6
5
|
Account.create!(name: 'client')
|
7
6
|
end
|
@@ -12,26 +11,25 @@ describe 'tenant' do
|
|
12
11
|
|
13
12
|
context 'without index: true' do
|
14
13
|
it 'does not create an index' do
|
15
|
-
expect(Immutable).not_to have_index_for(:
|
14
|
+
expect(Immutable).not_to have_index_for(client_id: 1)
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
18
|
context 'with index: true' do
|
20
19
|
it 'creates an index' do
|
21
|
-
expect(Indexable).to have_index_for(:
|
20
|
+
expect(Indexable).to have_index_for(client_id: 1)
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
24
|
context 'with full_indexes: true' do
|
26
25
|
it 'add the tenant field on each index' do
|
27
|
-
expect(Immutable).to have_index_for(:
|
26
|
+
expect(Immutable).to have_index_for(client_id: 1, title: 1)
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
31
30
|
context 'with full_indexes: false' do
|
32
31
|
it 'does not add the tenant field on each index' do
|
33
|
-
expect(Indexable).not_to have_index_for(:
|
32
|
+
expect(Indexable).not_to have_index_for(client_id: 1, title: 1)
|
34
33
|
end
|
35
34
|
end
|
36
|
-
|
37
35
|
end
|
data/spec/mandatory_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Mandatory do
|
4
|
-
|
5
4
|
let(:client) do
|
6
5
|
Account.create!(name: 'client')
|
7
6
|
end
|
@@ -17,6 +16,18 @@ describe Mandatory do
|
|
17
16
|
it_behaves_like 'a tenantable model'
|
18
17
|
it { is_expected.to validate_tenant_uniqueness_of(:slug) }
|
19
18
|
|
19
|
+
describe '.shared' do
|
20
|
+
it 'is defined' do
|
21
|
+
expect(Mandatory).to respond_to(:shared)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '.unshared' do
|
26
|
+
it 'is defined' do
|
27
|
+
expect(Mandatory).to respond_to(:unshared)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
20
31
|
describe '.default_scope' do
|
21
32
|
before do
|
22
33
|
Mongoid::Multitenancy.with_tenant(client) { @itemX = Mandatory.create!(title: 'title X', slug: 'article-x') }
|
data/spec/models/account.rb
CHANGED
data/spec/models/immutable.rb
CHANGED
@@ -4,12 +4,12 @@ class Immutable
|
|
4
4
|
|
5
5
|
tenant(:client, class_name: 'Account', immutable: true)
|
6
6
|
|
7
|
-
field :slug, :
|
8
|
-
field :title, :
|
7
|
+
field :slug, type: String
|
8
|
+
field :title, type: String
|
9
9
|
|
10
10
|
validates_tenant_uniqueness_of :slug
|
11
11
|
validates_presence_of :slug
|
12
12
|
validates_presence_of :title
|
13
13
|
|
14
|
-
index(
|
14
|
+
index(title: 1)
|
15
15
|
end
|
data/spec/models/indexable.rb
CHANGED
data/spec/models/mandatory.rb
CHANGED
@@ -5,11 +5,11 @@ class Mandatory
|
|
5
5
|
tenant(:client, class_name: 'Account')
|
6
6
|
|
7
7
|
field :slug, type: String
|
8
|
-
field :title, type:String
|
8
|
+
field :title, type: String
|
9
9
|
|
10
10
|
validates_tenant_uniqueness_of :slug
|
11
11
|
validates_presence_of :slug
|
12
12
|
validates_presence_of :title
|
13
13
|
|
14
|
-
index(
|
14
|
+
index(title: 1)
|
15
15
|
end
|
data/spec/models/mutable.rb
CHANGED
@@ -4,12 +4,12 @@ class Mutable
|
|
4
4
|
|
5
5
|
tenant :client, class_name: 'Account', immutable: false, optional: false
|
6
6
|
|
7
|
-
field :slug, :
|
8
|
-
field :title, :
|
7
|
+
field :slug, type: String
|
8
|
+
field :title, type: String
|
9
9
|
|
10
10
|
validates_tenant_uniqueness_of :slug
|
11
11
|
validates_presence_of :slug
|
12
12
|
validates_presence_of :title
|
13
13
|
|
14
|
-
index(
|
14
|
+
index(title: 1)
|
15
15
|
end
|
data/spec/models/optional.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
class OptionalExclude
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Multitenancy::Document
|
4
|
+
|
5
|
+
tenant(:client, class_name: 'Account', optional: true)
|
6
|
+
|
7
|
+
field :slug, type: String
|
8
|
+
field :title, type: String
|
9
|
+
|
10
|
+
validates_tenant_uniqueness_of :slug, exclude_shared: true
|
11
|
+
validates_presence_of :slug
|
12
|
+
validates_presence_of :title
|
13
|
+
|
14
|
+
index(title: 1)
|
15
|
+
end
|
@@ -21,7 +21,7 @@ describe Mongoid::Multitenancy do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'restores the current tenant after the block' do
|
24
|
-
Mongoid::Multitenancy.with_tenant(another_client)
|
24
|
+
Mongoid::Multitenancy.with_tenant(another_client) { ; }
|
25
25
|
expect(Mongoid::Multitenancy.current_tenant).to eq client
|
26
26
|
end
|
27
27
|
end
|
data/spec/mutable_child_spec.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OptionalExclude do
|
4
|
+
let(:client) do
|
5
|
+
Account.create!(name: 'client')
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:another_client) do
|
9
|
+
Account.create!(name: 'another client')
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:item) do
|
13
|
+
OptionalExclude.new(title: 'title X', slug: 'page-x')
|
14
|
+
end
|
15
|
+
|
16
|
+
it_behaves_like 'a tenantable model'
|
17
|
+
|
18
|
+
describe '#valid?' do
|
19
|
+
context 'with a tenant' do
|
20
|
+
before do
|
21
|
+
Mongoid::Multitenancy.current_tenant = client
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'is valid' do
|
25
|
+
expect(item).to be_valid
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with a uniqueness constraint' do
|
29
|
+
let(:duplicate) do
|
30
|
+
OptionalExclude.new(title: 'title Y', slug: 'page-x')
|
31
|
+
end
|
32
|
+
|
33
|
+
before do
|
34
|
+
item.save!
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'does not allow duplicates on the same tenant' do
|
38
|
+
expect(duplicate).not_to be_valid
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allow duplicates on a different same tenant' do
|
42
|
+
Mongoid::Multitenancy.with_tenant(another_client) do
|
43
|
+
expect(duplicate).to be_valid
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'without a tenant' do
|
50
|
+
it 'is valid' do
|
51
|
+
expect(item).to be_valid
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'with a uniqueness constraint' do
|
55
|
+
let(:duplicate) do
|
56
|
+
OptionalExclude.new(title: 'title Y', slug: 'page-x')
|
57
|
+
end
|
58
|
+
|
59
|
+
before do
|
60
|
+
item.save!
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'allow duplicates on any client' do
|
64
|
+
Mongoid::Multitenancy.with_tenant(client) do
|
65
|
+
expect(duplicate).to be_valid
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/optional_spec.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NoScopable do
|
4
|
+
it_behaves_like 'a tenantable model' do
|
5
|
+
let(:client) do
|
6
|
+
Account.create!(name: 'client')
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:another_client) do
|
10
|
+
Account.create!(name: 'another client')
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:item) do
|
14
|
+
NoScopable.new(title: 'title X', slug: 'page-x')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.shared' do
|
19
|
+
it 'is not defined' do
|
20
|
+
expect(NoScopable).not_to respond_to(:shared)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.unshared' do
|
25
|
+
it 'is not defined' do
|
26
|
+
expect(NoScopable).not_to respond_to(:unshared)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aymeric Brisse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -58,11 +58,15 @@ files:
|
|
58
58
|
- spec/models/mandatory.rb
|
59
59
|
- spec/models/mutable.rb
|
60
60
|
- spec/models/mutable_child.rb
|
61
|
+
- spec/models/no_scopable.rb
|
61
62
|
- spec/models/optional.rb
|
63
|
+
- spec/models/optional_exclude.rb
|
62
64
|
- spec/mongoid-multitenancy_spec.rb
|
63
65
|
- spec/mutable_child_spec.rb
|
64
66
|
- spec/mutable_spec.rb
|
67
|
+
- spec/optional_exclude_spec.rb
|
65
68
|
- spec/optional_spec.rb
|
69
|
+
- spec/scopable_spec.rb
|
66
70
|
- spec/spec_helper.rb
|
67
71
|
- spec/support/mongoid_matchers.rb
|
68
72
|
- spec/support/shared_examples.rb
|
@@ -86,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
90
|
version: '0'
|
87
91
|
requirements: []
|
88
92
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.4.5.1
|
90
94
|
signing_key:
|
91
95
|
specification_version: 4
|
92
96
|
summary: Support of a multi-tenant database with Mongoid
|
@@ -101,11 +105,15 @@ test_files:
|
|
101
105
|
- spec/models/mandatory.rb
|
102
106
|
- spec/models/mutable.rb
|
103
107
|
- spec/models/mutable_child.rb
|
108
|
+
- spec/models/no_scopable.rb
|
104
109
|
- spec/models/optional.rb
|
110
|
+
- spec/models/optional_exclude.rb
|
105
111
|
- spec/mongoid-multitenancy_spec.rb
|
106
112
|
- spec/mutable_child_spec.rb
|
107
113
|
- spec/mutable_spec.rb
|
114
|
+
- spec/optional_exclude_spec.rb
|
108
115
|
- spec/optional_spec.rb
|
116
|
+
- spec/scopable_spec.rb
|
109
117
|
- spec/spec_helper.rb
|
110
118
|
- spec/support/mongoid_matchers.rb
|
111
119
|
- spec/support/shared_examples.rb
|