rails_multitenant 0.10.0 → 0.11.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 +5 -5
- data/.travis.yml +3 -1
- data/CHANGELOG.md +4 -0
- data/README.md +9 -0
- data/lib/rails_multitenant.rb +6 -0
- data/lib/rails_multitenant/version.rb +1 -1
- data/rails_multitenant.gemspec +1 -1
- data/spec/rails_multitenant_spec.rb +51 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c9936e0904797c7af7fb67e3a08102b5d4388be
|
4
|
+
data.tar.gz: 5ba8bb69723b5d3b83007d6b5ad2148aa9769a50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1affba9e932ba4ffd61a034382a05fcc7027701137bafd215345451173ec5d92ef087366acf101db4e8fa48220f33c1b4649b33cb1b57c77c05b99db2de5bda
|
7
|
+
data.tar.gz: d7e99b00fe2ef9bd7070b7074a0ea09e6a7a35a70554f62b095843318086da92a231543530132c95f316b913d01a3f71d062aa22b2d9cb2f3ee116188480e6be
|
data/.travis.yml
CHANGED
@@ -24,4 +24,6 @@ matrix:
|
|
24
24
|
env: RAILS_VERSION="~> 4.1.16"
|
25
25
|
- rvm: 2.5.1
|
26
26
|
env: RAILS_VERSION="~> 4.1.16"
|
27
|
-
before_install:
|
27
|
+
before_install:
|
28
|
+
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
29
|
+
- gem install bundler -v '< 2'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### 0.11.0
|
4
|
+
* Provide shorthands to access `RailsMultitenant::GlobalContextRegistry` methods via `RailsMultitenant`.
|
5
|
+
For example `RailsMultitenant[:organization_id] = 'some value'` will set that value in the registry.
|
6
|
+
|
3
7
|
### 0.10.0
|
4
8
|
* Rails 5.2 support.
|
5
9
|
|
data/README.md
CHANGED
@@ -99,6 +99,15 @@ end
|
|
99
99
|
By default this adds an ActiveRecord validation to ensure the tenant model is present but this can be disabled
|
100
100
|
by passing `required: false` to `multitenant_on_model`.
|
101
101
|
|
102
|
+
### Shorthand
|
103
|
+
|
104
|
+
When using `rails-multitenant` in a project, it is common to need to set values in `RailsMultitenant::GlobalContextRegistry` at the rails console.
|
105
|
+
|
106
|
+
This is difficult to type. Alternatively you can shorten it to `RailsMultitenant`. For example you might type `RailsMultitenant[:organization_id] = 'some value'` and it will have the same effect as the long version.
|
107
|
+
|
108
|
+
This is mainly intended as a console convenience. Using the long form in source code is fine, and more explicit.
|
109
|
+
|
110
|
+
|
102
111
|
## Development
|
103
112
|
|
104
113
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/rails_multitenant.rb
CHANGED
@@ -6,4 +6,10 @@ require "rails_multitenant/multitenant_model"
|
|
6
6
|
|
7
7
|
require "rails_multitenant/middleware/extensions"
|
8
8
|
|
9
|
+
module RailsMultitenant
|
10
|
+
extend self
|
11
|
+
|
12
|
+
delegate :get, :[], :fetch, :set, :[]=, :delete, :with_isolated_registry, to: :GlobalContextRegistry
|
13
|
+
end
|
14
|
+
|
9
15
|
# rails_multitenant/rspec has to be explicitly included by clients who want to use it
|
data/rails_multitenant.gemspec
CHANGED
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'rake', '< 11.0'
|
30
30
|
spec.add_development_dependency 'rspec', '~> 2'
|
31
31
|
spec.add_development_dependency 'simplecov', '~> 0.15.1'
|
32
|
-
spec.add_development_dependency 'sqlite3'
|
32
|
+
spec.add_development_dependency 'sqlite3', '~> 1.3.0'
|
33
33
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
describe "delegating to GlobalContextRegistry" do
|
2
|
+
it "RailsMultitenant.get returns values from the GlobalContextRegistry" do
|
3
|
+
RailsMultitenant::GlobalContextRegistry.set(:organization_id, 'Salsify Housing Authority')
|
4
|
+
|
5
|
+
expect(RailsMultitenant.get(:organization_id)).to eq('Salsify Housing Authority')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "RailsMultitenant[] returns values from the GlobalContextRegistry" do
|
9
|
+
RailsMultitenant::GlobalContextRegistry.set(:organization_id, 'Salsify Farmland Inc.')
|
10
|
+
|
11
|
+
expect(RailsMultitenant[:organization_id]).to eq('Salsify Farmland Inc.')
|
12
|
+
end
|
13
|
+
|
14
|
+
it "RailsMultitenant.set assigns values in the GlobalContextRegistry" do
|
15
|
+
RailsMultitenant.set(:organization_id, 'Salsify Eminient Domain')
|
16
|
+
|
17
|
+
expect(RailsMultitenant::GlobalContextRegistry.get(:organization_id)).to eq('Salsify Eminient Domain')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "RailsMultitenant[]= assigns values in the GlobalContextRegistry" do
|
21
|
+
RailsMultitenant[:organization_id] = 'Salsify Co-op'
|
22
|
+
|
23
|
+
expect(RailsMultitenant::GlobalContextRegistry[:organization_id]).to eq('Salsify Co-op')
|
24
|
+
end
|
25
|
+
|
26
|
+
it "RailsMultitenant.fetch checks and sets the GlobalContextRegistry" do
|
27
|
+
RailsMultitenant::GlobalContextRegistry[:organization_id] = nil
|
28
|
+
|
29
|
+
expect(RailsMultitenant.fetch(:organization_id) { 'Salsify Anarchists' }).to eq('Salsify Anarchists')
|
30
|
+
|
31
|
+
expect(RailsMultitenant.fetch(:organization_id) { 'Salsify Crypto Anarchists' }).to eq('Salsify Anarchists')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "RailsMultitenant.delete removes from the GlobalContextRegistry" do
|
35
|
+
RailsMultitenant::GlobalContextRegistry[:organization_id] = 'Not Salsify'
|
36
|
+
|
37
|
+
RailsMultitenant.delete(:organization_id)
|
38
|
+
|
39
|
+
expect(RailsMultitenant.get(:organization_id)).to be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "RailsMultitenant.with_isolated_registry leverages the GlobalContextRegistry" do
|
43
|
+
RailsMultitenant::GlobalContextRegistry[:organization_id] = 'Salsify Mainland'
|
44
|
+
|
45
|
+
RailsMultitenant.with_isolated_registry({ organization_id: 'Salsify Private Island' }) do
|
46
|
+
expect(RailsMultitenant::GlobalContextRegistry[:organization_id]).to eq('Salsify Private Island')
|
47
|
+
end
|
48
|
+
|
49
|
+
expect(RailsMultitenant::GlobalContextRegistry[:organization_id]).to eq('Salsify Mainland')
|
50
|
+
end
|
51
|
+
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.11.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:
|
11
|
+
date: 2019-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,16 +138,16 @@ dependencies:
|
|
138
138
|
name: sqlite3
|
139
139
|
requirement: !ruby/object:Gem::Requirement
|
140
140
|
requirements:
|
141
|
-
- - "
|
141
|
+
- - "~>"
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
143
|
+
version: 1.3.0
|
144
144
|
type: :development
|
145
145
|
prerelease: false
|
146
146
|
version_requirements: !ruby/object:Gem::Requirement
|
147
147
|
requirements:
|
148
|
-
- - "
|
148
|
+
- - "~>"
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
150
|
+
version: 1.3.0
|
151
151
|
description: Handles multiple tenants in a Rails environment
|
152
152
|
email:
|
153
153
|
- pbreault@salsify.com
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- spec/item_subtype_spec.rb
|
187
187
|
- spec/item_with_optional_org_spec.rb
|
188
188
|
- spec/middleware_isolated_context_registry_spec.rb
|
189
|
+
- spec/rails_multitenant_spec.rb
|
189
190
|
- spec/spec_helper.rb
|
190
191
|
homepage: https://github.com/salsify/rails-multitenant
|
191
192
|
licenses:
|
@@ -207,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
208
|
version: '0'
|
208
209
|
requirements: []
|
209
210
|
rubyforge_project:
|
210
|
-
rubygems_version: 2.
|
211
|
+
rubygems_version: 2.6.14
|
211
212
|
signing_key:
|
212
213
|
specification_version: 4
|
213
214
|
summary: Automatically configures multiple tenants in a Rails environment
|
@@ -222,5 +223,6 @@ test_files:
|
|
222
223
|
- spec/db/schema.rb
|
223
224
|
- spec/db/database.yml
|
224
225
|
- spec/be_multitenant_on_matcher_spec.rb
|
226
|
+
- spec/rails_multitenant_spec.rb
|
225
227
|
- spec/item_with_optional_org_spec.rb
|
226
228
|
- spec/middleware_isolated_context_registry_spec.rb
|