rails_multitenant 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/.travis.yml +5 -6
- data/CHANGELOG.md +6 -1
- data/lib/rails_multitenant/multitenant_model.rb +1 -3
- data/lib/rails_multitenant/rspec.rb +1 -1
- data/lib/rails_multitenant/version.rb +1 -1
- data/rails_multitenant.gemspec +2 -2
- data/spec/be_multitenant_on_matcher_spec.rb +4 -1
- data/spec/db/schema.rb +5 -0
- data/spec/external_item_spec.rb +0 -1
- data/spec/global_context_registry_spec.rb +0 -1
- data/spec/item_spec.rb +0 -2
- data/spec/item_subtype_spec.rb +37 -0
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff528a38b03db9f83d9665fc802a577fa10cc0cb
|
4
|
+
data.tar.gz: d75fb03a0907977a6f18cf1fdc8a32a183179e88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3fd2430828d14280bd19414b20079814babd2ae01d67eb783b2130e2ddb029bde5521ee3dd6cec73ed2e7150637be99ab83c4d635db0d450f072ec28a3a8688
|
7
|
+
data.tar.gz: dd556073c42ef36665285a03018e2042375b815195a879687ddbe8c65d79f643a612c359425d88d6f006e0f16813b34c3e95e4d519af82cf79409b8b4c5ce43a
|
data/.rspec
ADDED
data/.travis.yml
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
3
|
env:
|
4
|
-
- RAILS_VERSION="~>
|
5
|
-
- RAILS_VERSION="~> 4.
|
6
|
-
- RAILS_VERSION="~>
|
7
|
-
- RAILS_VERSION="~> 4.2.4"
|
4
|
+
- RAILS_VERSION="~> 4.1.16"
|
5
|
+
- RAILS_VERSION="~> 4.2.7"
|
6
|
+
- RAILS_VERSION="~> 5.0.0"
|
8
7
|
rvm:
|
9
|
-
- 2.
|
10
|
-
before_install: gem install bundler -v 1.
|
8
|
+
- 2.3.1
|
9
|
+
before_install: gem install bundler -v 1.12.5
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
### 0.
|
3
|
+
### 0.4.0
|
4
|
+
* Fix be_multitenant_on matcher to handle models that don't include the `RailsMultitenant::MultitenantModel` module.
|
5
|
+
* Fix `context_entity_id_field` to work with inheritance.
|
6
|
+
* Drop Rails 3.2 and 4.0 support since `unscope` doesn't work propertly with default scopes.
|
7
|
+
|
8
|
+
### 0.3.1
|
4
9
|
* Fix strip_<entity>_scope
|
5
10
|
|
6
11
|
### 0.3.0
|
data/rails_multitenant.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_development_dependency "bundler", "~> 1.10"
|
21
21
|
|
22
|
-
spec.add_dependency 'activerecord', ENV.fetch('RAILS_VERSION', ['>=
|
23
|
-
spec.add_dependency 'activesupport', ENV.fetch('RAILS_VERSION', ['>=
|
22
|
+
spec.add_dependency 'activerecord', ENV.fetch('RAILS_VERSION', ['>= 4.1', '< 5.1'])
|
23
|
+
spec.add_dependency 'activesupport', ENV.fetch('RAILS_VERSION', ['>= 4.1', '< 5.1'])
|
24
24
|
|
25
25
|
spec.add_development_dependency 'coveralls'
|
26
26
|
spec.add_development_dependency 'database_cleaner', '>= 1.2'
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
1
|
require 'rails_multitenant/rspec'
|
3
2
|
|
4
3
|
describe "be_multitenant_on matcher" do
|
@@ -9,4 +8,8 @@ describe "be_multitenant_on matcher" do
|
|
9
8
|
it "rejects an invalid context field id" do
|
10
9
|
expect(ExternalItem).not_to be_multitenant_on(:other_field)
|
11
10
|
end
|
11
|
+
|
12
|
+
it "rejects classes that don't have a context field id" do
|
13
|
+
expect(String).not_to be_multitenant_on(:other_field)
|
14
|
+
end
|
12
15
|
end
|
data/spec/db/schema.rb
CHANGED
@@ -6,6 +6,7 @@ ActiveRecord::Schema.define(version: 0) do
|
|
6
6
|
|
7
7
|
create_table(:items, force: true) do |t|
|
8
8
|
t.integer :organization_id
|
9
|
+
t.string :type
|
9
10
|
end
|
10
11
|
|
11
12
|
create_table(:external_items, force: true) do |t|
|
@@ -22,6 +23,10 @@ class Item < ActiveRecord::Base
|
|
22
23
|
multitenant_on_model :organization
|
23
24
|
end
|
24
25
|
|
26
|
+
class ItemSubtype < Item
|
27
|
+
|
28
|
+
end
|
29
|
+
|
25
30
|
class ExternalItem < ActiveRecord::Base
|
26
31
|
include RailsMultitenant::MultitenantModel
|
27
32
|
multitenant_on :external_organization_id
|
data/spec/external_item_spec.rb
CHANGED
data/spec/item_spec.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Create multiple orgs
|
2
|
+
# Create an item in each
|
3
|
+
# Make sure you can only see one org's item in one org
|
4
|
+
|
5
|
+
describe ItemSubtype do
|
6
|
+
|
7
|
+
let!(:item1) { ItemSubtype.create! }
|
8
|
+
|
9
|
+
let!(:org2) { Organization.create! }
|
10
|
+
let!(:item2) { org2.as_current { ItemSubtype.create! } }
|
11
|
+
let!(:item3) { org2.as_current { ItemSubtype.create! } }
|
12
|
+
|
13
|
+
it 'inherits the multitenant settings from its parent class' do
|
14
|
+
expect(ItemSubtype).to be_multitenant_on(:organization_id)
|
15
|
+
end
|
16
|
+
|
17
|
+
specify 'default org should have one item' do
|
18
|
+
expect(ItemSubtype.all).to eq([item1])
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not return item2' do
|
22
|
+
expect(ItemSubtype.where(id: item2.id)).to eq([])
|
23
|
+
end
|
24
|
+
|
25
|
+
specify 'org2 should have two items' do
|
26
|
+
org2.as_current do
|
27
|
+
expect(ItemSubtype.all).to eq([item2, item3])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'does not return item1' do
|
32
|
+
org2.as_current do
|
33
|
+
expect(ItemSubtype.where(id: item1.id)).to eq([])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_multitenant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Breault
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,40 +30,40 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.1'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
36
|
+
version: '5.1'
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '4.1'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '5.1'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '4.1'
|
54
54
|
- - "<"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '5.1'
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '
|
63
|
+
version: '4.1'
|
64
64
|
- - "<"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
66
|
+
version: '5.1'
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: coveralls
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,6 +156,7 @@ extensions: []
|
|
156
156
|
extra_rdoc_files: []
|
157
157
|
files:
|
158
158
|
- ".gitignore"
|
159
|
+
- ".rspec"
|
159
160
|
- ".ruby-version"
|
160
161
|
- ".travis.yml"
|
161
162
|
- CHANGELOG.md
|
@@ -177,6 +178,7 @@ files:
|
|
177
178
|
- spec/external_item_spec.rb
|
178
179
|
- spec/global_context_registry_spec.rb
|
179
180
|
- spec/item_spec.rb
|
181
|
+
- spec/item_subtype_spec.rb
|
180
182
|
- spec/spec_helper.rb
|
181
183
|
homepage: https://github.com/salsify/rails_multitenant
|
182
184
|
licenses:
|
@@ -209,4 +211,5 @@ test_files:
|
|
209
211
|
- spec/external_item_spec.rb
|
210
212
|
- spec/global_context_registry_spec.rb
|
211
213
|
- spec/item_spec.rb
|
214
|
+
- spec/item_subtype_spec.rb
|
212
215
|
- spec/spec_helper.rb
|