activerecord-multi-tenant 1.0.0 → 1.1.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +6 -14
  4. data/Appraisals +24 -24
  5. data/CHANGELOG.md +22 -0
  6. data/Gemfile.lock +79 -63
  7. data/README.md +1 -1
  8. data/activerecord-multi-tenant.gemspec +1 -1
  9. data/gemfiles/.bundle/config +2 -0
  10. data/gemfiles/active_record_5.2.gemfile +10 -2
  11. data/gemfiles/active_record_5.2.gemfile.lock +102 -96
  12. data/gemfiles/{active_record_5.1.gemfile → active_record_6.0.gemfile} +2 -2
  13. data/gemfiles/active_record_6.0.gemfile.lock +198 -0
  14. data/gemfiles/rails_5.2.gemfile +10 -2
  15. data/gemfiles/rails_5.2.gemfile.lock +109 -103
  16. data/gemfiles/{rails_5.0.gemfile → rails_6.0.gemfile} +2 -2
  17. data/gemfiles/rails_6.0.gemfile.lock +198 -0
  18. data/lib/activerecord-multi-tenant.rb +1 -0
  19. data/lib/activerecord-multi-tenant/controller_extensions.rb +2 -6
  20. data/lib/activerecord-multi-tenant/copy_from_client.rb +2 -2
  21. data/lib/activerecord-multi-tenant/migrations.rb +2 -2
  22. data/lib/activerecord-multi-tenant/model_extensions.rb +8 -15
  23. data/lib/activerecord-multi-tenant/multi_tenant.rb +9 -0
  24. data/lib/activerecord-multi-tenant/persistence_extension.rb +13 -0
  25. data/lib/activerecord-multi-tenant/query_rewriter.rb +59 -105
  26. data/lib/activerecord-multi-tenant/sidekiq.rb +2 -1
  27. data/lib/activerecord-multi-tenant/version.rb +1 -1
  28. data/spec/activerecord-multi-tenant/controller_extensions_spec.rb +19 -24
  29. data/spec/activerecord-multi-tenant/model_extensions_spec.rb +54 -104
  30. data/spec/activerecord-multi-tenant/query_rewriter_spec.rb +40 -0
  31. data/spec/activerecord-multi-tenant/record_modifications_spec.rb +60 -3
  32. data/spec/activerecord-multi-tenant/schema_dumper_tester.rb +0 -0
  33. data/spec/activerecord-multi-tenant/sidekiq_spec.rb +4 -4
  34. data/spec/schema.rb +1 -4
  35. data/spec/spec_helper.rb +1 -6
  36. metadata +15 -20
  37. data/gemfiles/active_record_5.1.gemfile.lock +0 -173
  38. data/gemfiles/rails_4.0.gemfile +0 -8
  39. data/gemfiles/rails_4.0.gemfile.lock +0 -141
  40. data/gemfiles/rails_4.1.gemfile +0 -8
  41. data/gemfiles/rails_4.1.gemfile.lock +0 -146
  42. data/gemfiles/rails_4.2.gemfile +0 -8
  43. data/gemfiles/rails_4.2.gemfile.lock +0 -169
  44. data/gemfiles/rails_5.0.gemfile.lock +0 -175
  45. data/gemfiles/rails_5.1.gemfile +0 -8
  46. data/gemfiles/rails_5.1.gemfile.lock +0 -175
@@ -4,14 +4,14 @@ require 'activerecord-multi-tenant/sidekiq'
4
4
 
5
5
  describe MultiTenant, 'Sidekiq' do
6
6
  let(:server) { Sidekiq::Middleware::MultiTenant::Server.new }
7
+ let(:account) { Account.create(name: 'test') }
7
8
 
8
9
  describe 'server middleware' do
9
10
  it 'sets the multitenant context when provided in message' do
10
- tenant_id = 1234
11
- server.call(double, {'bogus' => 'message',
12
- 'multi_tenant' => { 'class' => MultiTenant.current_tenant_class, 'id' => tenant_id}},
11
+ server.call(double,{'bogus' => 'message',
12
+ 'multi_tenant' => { 'class' => account.class.name, 'id' => account.id}},
13
13
  'bogus_queue') do
14
- expect(MultiTenant.current_tenant).to eq(tenant_id)
14
+ expect(MultiTenant.current_tenant).to eq(account)
15
15
  end
16
16
  end
17
17
 
@@ -181,10 +181,7 @@ end
181
181
  class Comment < ActiveRecord::Base
182
182
  multi_tenant :account
183
183
  belongs_to :commentable, polymorphic: true
184
-
185
- if ActiveRecord::VERSION::MAJOR >= 4
186
- belongs_to :task, -> { where(comments: { commentable_type: 'Task' }) }, foreign_key: 'commentable_id'
187
- end
184
+ belongs_to :task, -> { where(comments: { commentable_type: 'Task' }) }, foreign_key: 'commentable_id'
188
185
  end
189
186
 
190
187
  class Organization < ActiveRecord::Base
@@ -43,12 +43,7 @@ MultiTenantTest::Application.config.secret_token = 'x' * 40
43
43
  MultiTenantTest::Application.config.secret_key_base = 'y' * 40
44
44
 
45
45
  def uses_prepared_statements?
46
- if ActiveRecord::VERSION::MAJOR == 4
47
- config = ActiveRecord::Base.connection.instance_variable_get(:@config)
48
- config.fetch(:prepared_statements, true)
49
- else
50
- ActiveRecord::Base.connection.prepared_statements
51
- end
46
+ ActiveRecord::Base.connection.prepared_statements
52
47
  end
53
48
 
54
49
  require 'schema'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-multi-tenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Citus Data
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-10 00:00:00.000000000 Z
11
+ date: 2020-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: request_store
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '4.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -167,22 +167,15 @@ files:
167
167
  - Rakefile
168
168
  - activerecord-multi-tenant.gemspec
169
169
  - docker-compose.yml
170
- - gemfiles/active_record_5.1.gemfile
171
- - gemfiles/active_record_5.1.gemfile.lock
170
+ - gemfiles/.bundle/config
172
171
  - gemfiles/active_record_5.2.gemfile
173
172
  - gemfiles/active_record_5.2.gemfile.lock
174
- - gemfiles/rails_4.0.gemfile
175
- - gemfiles/rails_4.0.gemfile.lock
176
- - gemfiles/rails_4.1.gemfile
177
- - gemfiles/rails_4.1.gemfile.lock
178
- - gemfiles/rails_4.2.gemfile
179
- - gemfiles/rails_4.2.gemfile.lock
180
- - gemfiles/rails_5.0.gemfile
181
- - gemfiles/rails_5.0.gemfile.lock
182
- - gemfiles/rails_5.1.gemfile
183
- - gemfiles/rails_5.1.gemfile.lock
173
+ - gemfiles/active_record_6.0.gemfile
174
+ - gemfiles/active_record_6.0.gemfile.lock
184
175
  - gemfiles/rails_5.2.gemfile
185
176
  - gemfiles/rails_5.2.gemfile.lock
177
+ - gemfiles/rails_6.0.gemfile
178
+ - gemfiles/rails_6.0.gemfile.lock
186
179
  - lib/activerecord-multi-tenant.rb
187
180
  - lib/activerecord-multi-tenant/controller_extensions.rb
188
181
  - lib/activerecord-multi-tenant/copy_from_client.rb
@@ -190,6 +183,7 @@ files:
190
183
  - lib/activerecord-multi-tenant/migrations.rb
191
184
  - lib/activerecord-multi-tenant/model_extensions.rb
192
185
  - lib/activerecord-multi-tenant/multi_tenant.rb
186
+ - lib/activerecord-multi-tenant/persistence_extension.rb
193
187
  - lib/activerecord-multi-tenant/query_monitor.rb
194
188
  - lib/activerecord-multi-tenant/query_rewriter.rb
195
189
  - lib/activerecord-multi-tenant/sidekiq.rb
@@ -203,6 +197,7 @@ files:
203
197
  - spec/activerecord-multi-tenant/record_callback_spec.rb
204
198
  - spec/activerecord-multi-tenant/record_finding_spec.rb
205
199
  - spec/activerecord-multi-tenant/record_modifications_spec.rb
200
+ - spec/activerecord-multi-tenant/schema_dumper_tester.rb
206
201
  - spec/activerecord-multi-tenant/sidekiq_spec.rb
207
202
  - spec/database.yml
208
203
  - spec/schema.rb
@@ -211,7 +206,7 @@ homepage: https://github.com/citusdata/activerecord-multi-tenant
211
206
  licenses:
212
207
  - MIT
213
208
  metadata: {}
214
- post_install_message:
209
+ post_install_message:
215
210
  rdoc_options: []
216
211
  require_paths:
217
212
  - lib
@@ -226,8 +221,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
221
  - !ruby/object:Gem::Version
227
222
  version: '0'
228
223
  requirements: []
229
- rubygems_version: 3.0.3
230
- signing_key:
224
+ rubygems_version: 3.1.2
225
+ signing_key:
231
226
  specification_version: 4
232
227
  summary: ActiveRecord/Rails integration for multi-tenant databases, in particular
233
228
  the Citus extension for PostgreSQL
@@ -1,173 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- activerecord-multi-tenant (1.0.0)
5
- rails (>= 4.0)
6
- request_store (>= 1.0.5)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actioncable (5.1.0)
12
- actionpack (= 5.1.0)
13
- nio4r (~> 2.0)
14
- websocket-driver (~> 0.6.1)
15
- actionmailer (5.1.0)
16
- actionpack (= 5.1.0)
17
- actionview (= 5.1.0)
18
- activejob (= 5.1.0)
19
- mail (~> 2.5, >= 2.5.4)
20
- rails-dom-testing (~> 2.0)
21
- actionpack (5.1.0)
22
- actionview (= 5.1.0)
23
- activesupport (= 5.1.0)
24
- rack (~> 2.0)
25
- rack-test (~> 0.6.3)
26
- rails-dom-testing (~> 2.0)
27
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- actionview (5.1.0)
29
- activesupport (= 5.1.0)
30
- builder (~> 3.1)
31
- erubi (~> 1.4)
32
- rails-dom-testing (~> 2.0)
33
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
- activejob (5.1.0)
35
- activesupport (= 5.1.0)
36
- globalid (>= 0.3.6)
37
- activemodel (5.1.0)
38
- activesupport (= 5.1.0)
39
- activerecord (5.1.0)
40
- activemodel (= 5.1.0)
41
- activesupport (= 5.1.0)
42
- arel (~> 8.0)
43
- activesupport (5.1.0)
44
- concurrent-ruby (~> 1.0, >= 1.0.2)
45
- i18n (~> 0.7)
46
- minitest (~> 5.1)
47
- tzinfo (~> 1.1)
48
- appraisal (2.2.0)
49
- bundler
50
- rake
51
- thor (>= 0.14.0)
52
- arel (8.0.0)
53
- builder (3.2.3)
54
- byebug (9.0.6)
55
- coderay (1.1.1)
56
- concurrent-ruby (1.0.5)
57
- connection_pool (2.2.1)
58
- diff-lcs (1.3)
59
- erubi (1.6.0)
60
- globalid (0.4.2)
61
- activesupport (>= 4.2.0)
62
- i18n (0.8.1)
63
- loofah (2.0.3)
64
- nokogiri (>= 1.5.9)
65
- mail (2.7.1)
66
- mini_mime (>= 0.1.1)
67
- method_source (0.8.2)
68
- mini_mime (1.0.1)
69
- mini_portile2 (2.1.0)
70
- minitest (5.10.1)
71
- nio4r (2.3.1)
72
- nokogiri (1.7.1)
73
- mini_portile2 (~> 2.1.0)
74
- pg (0.20.0)
75
- pry (0.10.4)
76
- coderay (~> 1.1.0)
77
- method_source (~> 0.8.1)
78
- slop (~> 3.4)
79
- pry-byebug (3.4.2)
80
- byebug (~> 9.0)
81
- pry (~> 0.10)
82
- rack (2.0.5)
83
- rack-protection (1.5.3)
84
- rack
85
- rack-test (0.6.3)
86
- rack (>= 1.0)
87
- rails (5.1.0)
88
- actioncable (= 5.1.0)
89
- actionmailer (= 5.1.0)
90
- actionpack (= 5.1.0)
91
- actionview (= 5.1.0)
92
- activejob (= 5.1.0)
93
- activemodel (= 5.1.0)
94
- activerecord (= 5.1.0)
95
- activesupport (= 5.1.0)
96
- bundler (>= 1.3.0, < 2.0)
97
- railties (= 5.1.0)
98
- sprockets-rails (>= 2.0.0)
99
- rails-dom-testing (2.0.2)
100
- activesupport (>= 4.2.0, < 6.0)
101
- nokogiri (~> 1.6)
102
- rails-html-sanitizer (1.0.3)
103
- loofah (~> 2.0)
104
- railties (5.1.0)
105
- actionpack (= 5.1.0)
106
- activesupport (= 5.1.0)
107
- method_source
108
- rake (>= 0.8.7)
109
- thor (>= 0.18.1, < 2.0)
110
- rake (12.0.0)
111
- redis (3.3.3)
112
- request_store (1.4.1)
113
- rack (>= 1.4)
114
- rspec (3.6.0)
115
- rspec-core (~> 3.6.0)
116
- rspec-expectations (~> 3.6.0)
117
- rspec-mocks (~> 3.6.0)
118
- rspec-core (3.6.0)
119
- rspec-support (~> 3.6.0)
120
- rspec-expectations (3.6.0)
121
- diff-lcs (>= 1.2.0, < 2.0)
122
- rspec-support (~> 3.6.0)
123
- rspec-mocks (3.6.0)
124
- diff-lcs (>= 1.2.0, < 2.0)
125
- rspec-support (~> 3.6.0)
126
- rspec-rails (3.6.0)
127
- actionpack (>= 3.0)
128
- activesupport (>= 3.0)
129
- railties (>= 3.0)
130
- rspec-core (~> 3.6.0)
131
- rspec-expectations (~> 3.6.0)
132
- rspec-mocks (~> 3.6.0)
133
- rspec-support (~> 3.6.0)
134
- rspec-support (3.6.0)
135
- sidekiq (4.2.10)
136
- concurrent-ruby (~> 1.0)
137
- connection_pool (~> 2.2, >= 2.2.0)
138
- rack-protection (>= 1.5.0)
139
- redis (~> 3.2, >= 3.2.1)
140
- slop (3.6.0)
141
- sprockets (3.7.2)
142
- concurrent-ruby (~> 1.0)
143
- rack (> 1, < 3)
144
- sprockets-rails (3.2.1)
145
- actionpack (>= 4.0)
146
- activesupport (>= 4.0)
147
- sprockets (>= 3.0.0)
148
- thor (0.19.4)
149
- thread_safe (0.3.6)
150
- tzinfo (1.2.3)
151
- thread_safe (~> 0.1)
152
- websocket-driver (0.6.5)
153
- websocket-extensions (>= 0.1.0)
154
- websocket-extensions (0.1.4)
155
-
156
- PLATFORMS
157
- ruby
158
-
159
- DEPENDENCIES
160
- activerecord (= 5.1.0)
161
- activerecord-multi-tenant!
162
- appraisal
163
- pg
164
- pry
165
- pry-byebug
166
- rake
167
- rspec (>= 3.0)
168
- rspec-rails
169
- sidekiq
170
- thor
171
-
172
- BUNDLED WITH
173
- 1.17.2
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "rails", "4.0.13"
7
-
8
- gemspec :path => "../"
@@ -1,141 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- activerecord-multi-tenant (1.0.0)
5
- rails (>= 4.0)
6
- request_store (>= 1.0.5)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actionmailer (4.0.13)
12
- actionpack (= 4.0.13)
13
- mail (~> 2.5, >= 2.5.4)
14
- actionpack (4.0.13)
15
- activesupport (= 4.0.13)
16
- builder (~> 3.1.0)
17
- erubis (~> 2.7.0)
18
- rack (~> 1.5.2)
19
- rack-test (~> 0.6.2)
20
- activemodel (4.0.13)
21
- activesupport (= 4.0.13)
22
- builder (~> 3.1.0)
23
- activerecord (4.0.13)
24
- activemodel (= 4.0.13)
25
- activerecord-deprecated_finders (~> 1.0.2)
26
- activesupport (= 4.0.13)
27
- arel (~> 4.0.0)
28
- activerecord-deprecated_finders (1.0.4)
29
- activesupport (4.0.13)
30
- i18n (~> 0.6, >= 0.6.9)
31
- minitest (~> 4.2)
32
- multi_json (~> 1.3)
33
- thread_safe (~> 0.1)
34
- tzinfo (~> 0.3.37)
35
- appraisal (2.1.0)
36
- bundler
37
- rake
38
- thor (>= 0.14.0)
39
- arel (4.0.2)
40
- builder (3.1.4)
41
- byebug (9.0.6)
42
- coderay (1.1.1)
43
- concurrent-ruby (1.0.5)
44
- connection_pool (2.2.1)
45
- diff-lcs (1.3)
46
- erubis (2.7.0)
47
- i18n (0.8.1)
48
- mail (2.6.4)
49
- mime-types (>= 1.16, < 4)
50
- method_source (0.8.2)
51
- mime-types (3.1)
52
- mime-types-data (~> 3.2015)
53
- mime-types-data (3.2016.0521)
54
- minitest (4.7.5)
55
- multi_json (1.12.1)
56
- pg (0.20.0)
57
- pry (0.10.4)
58
- coderay (~> 1.1.0)
59
- method_source (~> 0.8.1)
60
- slop (~> 3.4)
61
- pry-byebug (3.4.2)
62
- byebug (~> 9.0)
63
- pry (~> 0.10)
64
- rack (1.5.5)
65
- rack-protection (2.0.0)
66
- rack
67
- rack-test (0.6.3)
68
- rack (>= 1.0)
69
- rails (4.0.13)
70
- actionmailer (= 4.0.13)
71
- actionpack (= 4.0.13)
72
- activerecord (= 4.0.13)
73
- activesupport (= 4.0.13)
74
- bundler (>= 1.3.0, < 2.0)
75
- railties (= 4.0.13)
76
- sprockets-rails (~> 2.0)
77
- railties (4.0.13)
78
- actionpack (= 4.0.13)
79
- activesupport (= 4.0.13)
80
- rake (>= 0.8.7)
81
- thor (>= 0.18.1, < 2.0)
82
- rake (12.0.0)
83
- redis (3.3.3)
84
- request_store (1.4.1)
85
- rack (>= 1.4)
86
- rspec (3.5.0)
87
- rspec-core (~> 3.5.0)
88
- rspec-expectations (~> 3.5.0)
89
- rspec-mocks (~> 3.5.0)
90
- rspec-core (3.5.4)
91
- rspec-support (~> 3.5.0)
92
- rspec-expectations (3.5.0)
93
- diff-lcs (>= 1.2.0, < 2.0)
94
- rspec-support (~> 3.5.0)
95
- rspec-mocks (3.5.0)
96
- diff-lcs (>= 1.2.0, < 2.0)
97
- rspec-support (~> 3.5.0)
98
- rspec-rails (3.5.2)
99
- actionpack (>= 3.0)
100
- activesupport (>= 3.0)
101
- railties (>= 3.0)
102
- rspec-core (~> 3.5.0)
103
- rspec-expectations (~> 3.5.0)
104
- rspec-mocks (~> 3.5.0)
105
- rspec-support (~> 3.5.0)
106
- rspec-support (3.5.0)
107
- sidekiq (5.0.3)
108
- concurrent-ruby (~> 1.0)
109
- connection_pool (~> 2.2, >= 2.2.0)
110
- rack-protection (>= 1.5.0)
111
- redis (~> 3.3, >= 3.3.3)
112
- slop (3.6.0)
113
- sprockets (3.7.1)
114
- concurrent-ruby (~> 1.0)
115
- rack (> 1, < 3)
116
- sprockets-rails (2.3.3)
117
- actionpack (>= 3.0)
118
- activesupport (>= 3.0)
119
- sprockets (>= 2.8, < 4.0)
120
- thor (0.19.4)
121
- thread_safe (0.3.6)
122
- tzinfo (0.3.53)
123
-
124
- PLATFORMS
125
- ruby
126
-
127
- DEPENDENCIES
128
- activerecord-multi-tenant!
129
- appraisal
130
- pg
131
- pry
132
- pry-byebug
133
- rails (= 4.0.13)
134
- rake
135
- rspec (>= 3.0)
136
- rspec-rails
137
- sidekiq
138
- thor
139
-
140
- BUNDLED WITH
141
- 1.17.2