acts_as_tenant 0.4.3 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +124 -25
  3. data/Rakefile +5 -3
  4. data/lib/acts_as_tenant/configuration.rb +6 -19
  5. data/lib/acts_as_tenant/controller_extensions/filter.rb +13 -0
  6. data/lib/acts_as_tenant/controller_extensions/subdomain.rb +20 -0
  7. data/lib/acts_as_tenant/controller_extensions/subdomain_or_domain.rb +20 -0
  8. data/lib/acts_as_tenant/controller_extensions.rb +10 -59
  9. data/lib/acts_as_tenant/errors.rb +3 -4
  10. data/lib/acts_as_tenant/model_extensions.rb +59 -136
  11. data/lib/acts_as_tenant/sidekiq.rb +11 -7
  12. data/lib/acts_as_tenant/tenant_helper.rb +7 -0
  13. data/lib/acts_as_tenant/test_tenant_middleware.rb +15 -0
  14. data/lib/acts_as_tenant/version.rb +1 -1
  15. data/lib/acts_as_tenant.rb +112 -14
  16. data/spec/acts_as_tenant/configuration_spec.rb +8 -19
  17. data/spec/acts_as_tenant/sidekiq_spec.rb +14 -19
  18. data/spec/{acts_as_tenant/tenant_by_filter_spec.rb → controllers/filter_spec.rb} +7 -12
  19. data/spec/controllers/subdomain_or_domain_spec.rb +55 -0
  20. data/spec/controllers/subdomain_spec.rb +49 -0
  21. data/spec/dummy/.ruby-version +1 -0
  22. data/spec/dummy/Rakefile +6 -0
  23. data/spec/dummy/app/assets/config/manifest.js +2 -0
  24. data/spec/dummy/app/assets/images/.keep +0 -0
  25. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  26. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  27. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  28. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  29. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  30. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  31. data/spec/dummy/app/javascript/packs/application.js +15 -0
  32. data/spec/dummy/app/jobs/application_job.rb +7 -0
  33. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  34. data/spec/dummy/app/mailers/user_mailer.rb +5 -0
  35. data/spec/dummy/app/models/account.rb +4 -0
  36. data/spec/dummy/app/models/aliased_task.rb +4 -0
  37. data/spec/dummy/app/models/article.rb +3 -0
  38. data/spec/dummy/app/models/comment.rb +5 -0
  39. data/spec/dummy/app/models/concerns/.keep +0 -0
  40. data/spec/dummy/app/models/custom_counter_cache_task.rb +4 -0
  41. data/spec/dummy/app/models/custom_foreign_key_task.rb +4 -0
  42. data/spec/dummy/app/models/custom_primary_key_task.rb +4 -0
  43. data/spec/dummy/app/models/global_project.rb +6 -0
  44. data/spec/dummy/app/models/global_project_with_conditions.rb +6 -0
  45. data/spec/dummy/app/models/global_project_with_if.rb +6 -0
  46. data/spec/dummy/app/models/manager.rb +4 -0
  47. data/spec/dummy/app/models/polymorphic_tenant_comment.rb +5 -0
  48. data/spec/dummy/app/models/project.rb +8 -0
  49. data/spec/dummy/app/models/task.rb +7 -0
  50. data/spec/dummy/app/models/unique_task.rb +5 -0
  51. data/spec/dummy/app/models/unscoped_model.rb +3 -0
  52. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  53. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  54. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  55. data/spec/dummy/bin/rails +4 -0
  56. data/spec/dummy/bin/rake +4 -0
  57. data/spec/dummy/bin/setup +33 -0
  58. data/spec/dummy/config/application.rb +19 -0
  59. data/spec/dummy/config/boot.rb +5 -0
  60. data/spec/dummy/config/cable.yml +10 -0
  61. data/spec/dummy/config/database.yml +19 -0
  62. data/spec/dummy/config/environment.rb +5 -0
  63. data/spec/dummy/config/environments/development.rb +62 -0
  64. data/spec/dummy/config/environments/production.rb +112 -0
  65. data/spec/dummy/config/environments/test.rb +49 -0
  66. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  67. data/spec/dummy/config/initializers/assets.rb +12 -0
  68. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  69. data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
  70. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  71. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  72. data/spec/dummy/config/initializers/inflections.rb +16 -0
  73. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  74. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  75. data/spec/dummy/config/locales/en.yml +40 -0
  76. data/spec/dummy/config/puma.rb +38 -0
  77. data/spec/dummy/config/routes.rb +4 -0
  78. data/spec/dummy/config/spring.rb +6 -0
  79. data/spec/dummy/config/storage.yml +34 -0
  80. data/spec/dummy/config.ru +5 -0
  81. data/spec/dummy/db/schema.rb +84 -0
  82. data/spec/dummy/lib/assets/.keep +0 -0
  83. data/spec/dummy/log/.keep +0 -0
  84. data/spec/dummy/public/404.html +67 -0
  85. data/spec/dummy/public/422.html +67 -0
  86. data/spec/dummy/public/500.html +66 -0
  87. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  88. data/spec/dummy/public/apple-touch-icon.png +0 -0
  89. data/spec/dummy/public/favicon.ico +0 -0
  90. data/spec/dummy/tmp/development_secret.txt +1 -0
  91. data/spec/fixtures/accounts.yml +10 -0
  92. data/spec/fixtures/custom_primary_key_tasks.yml +2 -0
  93. data/spec/fixtures/global_projects.yml +13 -0
  94. data/spec/fixtures/projects.yml +10 -0
  95. data/spec/helpers/tenant_helper_spec.rb +16 -0
  96. data/spec/middlewares/test_tenant_middleware_spec.rb +86 -0
  97. data/spec/models/model_extensions_spec.rb +413 -0
  98. data/spec/spec_helper.rb +9 -13
  99. metadata +205 -41
  100. data/.gitignore +0 -7
  101. data/.travis.yml +0 -4
  102. data/CHANGELOG.md +0 -112
  103. data/Gemfile +0 -4
  104. data/_config.yml +0 -1
  105. data/acts_as_tenant.gemspec +0 -32
  106. data/docs/blog_post.md +0 -67
  107. data/rails/init.rb +0 -2
  108. data/spec/active_record_helper.rb +0 -22
  109. data/spec/active_record_models.rb +0 -116
  110. data/spec/acts_as_tenant/model_extensions_spec.rb +0 -420
  111. data/spec/acts_as_tenant/tenant_by_subdomain_or_domain.rb +0 -46
  112. data/spec/acts_as_tenant/tenant_by_subdomain_spec.rb +0 -32
  113. data/spec/database.yml +0 -3
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_tenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erwin Matthijssen
8
- autorequire:
8
+ - Chris Oliver
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2018-03-29 00:00:00.000000000 Z
12
+ date: 2021-09-09 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: request_store
@@ -30,14 +31,14 @@ dependencies:
30
31
  requirements:
31
32
  - - ">="
32
33
  - !ruby/object:Gem::Version
33
- version: '4.0'
34
+ version: '5.2'
34
35
  type: :runtime
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
39
  - - ">="
39
40
  - !ruby/object:Gem::Version
40
- version: '4.0'
41
+ version: '5.2'
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: rspec
43
44
  requirement: !ruby/object:Gem::Requirement
@@ -67,21 +68,41 @@ dependencies:
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  - !ruby/object:Gem::Dependency
70
- name: database_cleaner
71
+ name: sqlite3
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: sidekiq
71
86
  requirement: !ruby/object:Gem::Requirement
72
87
  requirements:
73
88
  - - "~>"
74
89
  - !ruby/object:Gem::Version
75
- version: 1.5.3
90
+ version: '6.1'
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: 6.1.2
76
94
  type: :development
77
95
  prerelease: false
78
96
  version_requirements: !ruby/object:Gem::Requirement
79
97
  requirements:
80
98
  - - "~>"
81
99
  - !ruby/object:Gem::Version
82
- version: 1.5.3
100
+ version: '6.1'
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 6.1.2
83
104
  - !ruby/object:Gem::Dependency
84
- name: sqlite3
105
+ name: standard
85
106
  requirement: !ruby/object:Gem::Requirement
86
107
  requirements:
87
108
  - - ">="
@@ -95,59 +116,130 @@ dependencies:
95
116
  - !ruby/object:Gem::Version
96
117
  version: '0'
97
118
  - !ruby/object:Gem::Dependency
98
- name: sidekiq
119
+ name: appraisal
99
120
  requirement: !ruby/object:Gem::Requirement
100
121
  requirements:
101
- - - '='
122
+ - - ">="
102
123
  - !ruby/object:Gem::Version
103
- version: 3.2.1
124
+ version: '0'
104
125
  type: :development
105
126
  prerelease: false
106
127
  version_requirements: !ruby/object:Gem::Requirement
107
128
  requirements:
108
- - - '='
129
+ - - ">="
109
130
  - !ruby/object:Gem::Version
110
- version: 3.2.1
131
+ version: '0'
111
132
  description: Integrates multi-tenancy into a Rails application in a convenient and
112
133
  out-of-your way manner
113
134
  email:
114
135
  - erwin.matthijssen@gmail.com
136
+ - excid3@gmail.com
115
137
  executables: []
116
138
  extensions: []
117
139
  extra_rdoc_files: []
118
140
  files:
119
- - ".gitignore"
120
- - ".travis.yml"
121
- - CHANGELOG.md
122
- - Gemfile
123
141
  - MIT-LICENSE
124
142
  - README.md
125
143
  - Rakefile
126
- - _config.yml
127
- - acts_as_tenant.gemspec
128
- - docs/blog_post.md
129
144
  - lib/acts_as_tenant.rb
130
145
  - lib/acts_as_tenant/configuration.rb
131
146
  - lib/acts_as_tenant/controller_extensions.rb
147
+ - lib/acts_as_tenant/controller_extensions/filter.rb
148
+ - lib/acts_as_tenant/controller_extensions/subdomain.rb
149
+ - lib/acts_as_tenant/controller_extensions/subdomain_or_domain.rb
132
150
  - lib/acts_as_tenant/errors.rb
133
151
  - lib/acts_as_tenant/model_extensions.rb
134
152
  - lib/acts_as_tenant/sidekiq.rb
153
+ - lib/acts_as_tenant/tenant_helper.rb
154
+ - lib/acts_as_tenant/test_tenant_middleware.rb
135
155
  - lib/acts_as_tenant/version.rb
136
- - rails/init.rb
137
- - spec/active_record_helper.rb
138
- - spec/active_record_models.rb
139
156
  - spec/acts_as_tenant/configuration_spec.rb
140
- - spec/acts_as_tenant/model_extensions_spec.rb
141
157
  - spec/acts_as_tenant/sidekiq_spec.rb
142
- - spec/acts_as_tenant/tenant_by_filter_spec.rb
143
- - spec/acts_as_tenant/tenant_by_subdomain_or_domain.rb
144
- - spec/acts_as_tenant/tenant_by_subdomain_spec.rb
145
- - spec/database.yml
158
+ - spec/controllers/filter_spec.rb
159
+ - spec/controllers/subdomain_or_domain_spec.rb
160
+ - spec/controllers/subdomain_spec.rb
161
+ - spec/dummy/.ruby-version
162
+ - spec/dummy/Rakefile
163
+ - spec/dummy/app/assets/config/manifest.js
164
+ - spec/dummy/app/assets/images/.keep
165
+ - spec/dummy/app/assets/stylesheets/application.css
166
+ - spec/dummy/app/channels/application_cable/channel.rb
167
+ - spec/dummy/app/channels/application_cable/connection.rb
168
+ - spec/dummy/app/controllers/application_controller.rb
169
+ - spec/dummy/app/controllers/concerns/.keep
170
+ - spec/dummy/app/helpers/application_helper.rb
171
+ - spec/dummy/app/javascript/packs/application.js
172
+ - spec/dummy/app/jobs/application_job.rb
173
+ - spec/dummy/app/mailers/application_mailer.rb
174
+ - spec/dummy/app/mailers/user_mailer.rb
175
+ - spec/dummy/app/models/account.rb
176
+ - spec/dummy/app/models/aliased_task.rb
177
+ - spec/dummy/app/models/article.rb
178
+ - spec/dummy/app/models/comment.rb
179
+ - spec/dummy/app/models/concerns/.keep
180
+ - spec/dummy/app/models/custom_counter_cache_task.rb
181
+ - spec/dummy/app/models/custom_foreign_key_task.rb
182
+ - spec/dummy/app/models/custom_primary_key_task.rb
183
+ - spec/dummy/app/models/global_project.rb
184
+ - spec/dummy/app/models/global_project_with_conditions.rb
185
+ - spec/dummy/app/models/global_project_with_if.rb
186
+ - spec/dummy/app/models/manager.rb
187
+ - spec/dummy/app/models/polymorphic_tenant_comment.rb
188
+ - spec/dummy/app/models/project.rb
189
+ - spec/dummy/app/models/task.rb
190
+ - spec/dummy/app/models/unique_task.rb
191
+ - spec/dummy/app/models/unscoped_model.rb
192
+ - spec/dummy/app/views/layouts/application.html.erb
193
+ - spec/dummy/app/views/layouts/mailer.html.erb
194
+ - spec/dummy/app/views/layouts/mailer.text.erb
195
+ - spec/dummy/bin/rails
196
+ - spec/dummy/bin/rake
197
+ - spec/dummy/bin/setup
198
+ - spec/dummy/config.ru
199
+ - spec/dummy/config/application.rb
200
+ - spec/dummy/config/boot.rb
201
+ - spec/dummy/config/cable.yml
202
+ - spec/dummy/config/database.yml
203
+ - spec/dummy/config/environment.rb
204
+ - spec/dummy/config/environments/development.rb
205
+ - spec/dummy/config/environments/production.rb
206
+ - spec/dummy/config/environments/test.rb
207
+ - spec/dummy/config/initializers/application_controller_renderer.rb
208
+ - spec/dummy/config/initializers/assets.rb
209
+ - spec/dummy/config/initializers/backtrace_silencers.rb
210
+ - spec/dummy/config/initializers/content_security_policy.rb
211
+ - spec/dummy/config/initializers/cookies_serializer.rb
212
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
213
+ - spec/dummy/config/initializers/inflections.rb
214
+ - spec/dummy/config/initializers/mime_types.rb
215
+ - spec/dummy/config/initializers/wrap_parameters.rb
216
+ - spec/dummy/config/locales/en.yml
217
+ - spec/dummy/config/puma.rb
218
+ - spec/dummy/config/routes.rb
219
+ - spec/dummy/config/spring.rb
220
+ - spec/dummy/config/storage.yml
221
+ - spec/dummy/db/schema.rb
222
+ - spec/dummy/lib/assets/.keep
223
+ - spec/dummy/log/.keep
224
+ - spec/dummy/public/404.html
225
+ - spec/dummy/public/422.html
226
+ - spec/dummy/public/500.html
227
+ - spec/dummy/public/apple-touch-icon-precomposed.png
228
+ - spec/dummy/public/apple-touch-icon.png
229
+ - spec/dummy/public/favicon.ico
230
+ - spec/dummy/tmp/development_secret.txt
231
+ - spec/fixtures/accounts.yml
232
+ - spec/fixtures/custom_primary_key_tasks.yml
233
+ - spec/fixtures/global_projects.yml
234
+ - spec/fixtures/projects.yml
235
+ - spec/helpers/tenant_helper_spec.rb
236
+ - spec/middlewares/test_tenant_middleware_spec.rb
237
+ - spec/models/model_extensions_spec.rb
146
238
  - spec/spec_helper.rb
147
- homepage: http://www.rollcallapp.com/blog
239
+ homepage: https://github.com/ErwinM/acts_as_tenant
148
240
  licenses: []
149
241
  metadata: {}
150
- post_install_message:
242
+ post_install_message:
151
243
  rdoc_options: []
152
244
  require_paths:
153
245
  - lib
@@ -162,19 +254,91 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
254
  - !ruby/object:Gem::Version
163
255
  version: '0'
164
256
  requirements: []
165
- rubyforge_project: acts_as_tenant
166
- rubygems_version: 2.6.11
167
- signing_key:
257
+ rubygems_version: 3.2.22
258
+ signing_key:
168
259
  specification_version: 4
169
260
  summary: Add multi-tenancy to Rails applications using a shared db strategy
170
261
  test_files:
171
- - spec/active_record_helper.rb
172
- - spec/active_record_models.rb
173
262
  - spec/acts_as_tenant/configuration_spec.rb
174
- - spec/acts_as_tenant/model_extensions_spec.rb
175
263
  - spec/acts_as_tenant/sidekiq_spec.rb
176
- - spec/acts_as_tenant/tenant_by_filter_spec.rb
177
- - spec/acts_as_tenant/tenant_by_subdomain_or_domain.rb
178
- - spec/acts_as_tenant/tenant_by_subdomain_spec.rb
179
- - spec/database.yml
264
+ - spec/controllers/filter_spec.rb
265
+ - spec/controllers/subdomain_or_domain_spec.rb
266
+ - spec/controllers/subdomain_spec.rb
267
+ - spec/dummy/.ruby-version
268
+ - spec/dummy/Rakefile
269
+ - spec/dummy/app/assets/config/manifest.js
270
+ - spec/dummy/app/assets/images/.keep
271
+ - spec/dummy/app/assets/stylesheets/application.css
272
+ - spec/dummy/app/channels/application_cable/channel.rb
273
+ - spec/dummy/app/channels/application_cable/connection.rb
274
+ - spec/dummy/app/controllers/application_controller.rb
275
+ - spec/dummy/app/controllers/concerns/.keep
276
+ - spec/dummy/app/helpers/application_helper.rb
277
+ - spec/dummy/app/javascript/packs/application.js
278
+ - spec/dummy/app/jobs/application_job.rb
279
+ - spec/dummy/app/mailers/application_mailer.rb
280
+ - spec/dummy/app/mailers/user_mailer.rb
281
+ - spec/dummy/app/models/account.rb
282
+ - spec/dummy/app/models/aliased_task.rb
283
+ - spec/dummy/app/models/article.rb
284
+ - spec/dummy/app/models/comment.rb
285
+ - spec/dummy/app/models/concerns/.keep
286
+ - spec/dummy/app/models/custom_counter_cache_task.rb
287
+ - spec/dummy/app/models/custom_foreign_key_task.rb
288
+ - spec/dummy/app/models/custom_primary_key_task.rb
289
+ - spec/dummy/app/models/global_project.rb
290
+ - spec/dummy/app/models/global_project_with_conditions.rb
291
+ - spec/dummy/app/models/global_project_with_if.rb
292
+ - spec/dummy/app/models/manager.rb
293
+ - spec/dummy/app/models/polymorphic_tenant_comment.rb
294
+ - spec/dummy/app/models/project.rb
295
+ - spec/dummy/app/models/task.rb
296
+ - spec/dummy/app/models/unique_task.rb
297
+ - spec/dummy/app/models/unscoped_model.rb
298
+ - spec/dummy/app/views/layouts/application.html.erb
299
+ - spec/dummy/app/views/layouts/mailer.html.erb
300
+ - spec/dummy/app/views/layouts/mailer.text.erb
301
+ - spec/dummy/bin/rails
302
+ - spec/dummy/bin/rake
303
+ - spec/dummy/bin/setup
304
+ - spec/dummy/config.ru
305
+ - spec/dummy/config/application.rb
306
+ - spec/dummy/config/boot.rb
307
+ - spec/dummy/config/cable.yml
308
+ - spec/dummy/config/database.yml
309
+ - spec/dummy/config/environment.rb
310
+ - spec/dummy/config/environments/development.rb
311
+ - spec/dummy/config/environments/production.rb
312
+ - spec/dummy/config/environments/test.rb
313
+ - spec/dummy/config/initializers/application_controller_renderer.rb
314
+ - spec/dummy/config/initializers/assets.rb
315
+ - spec/dummy/config/initializers/backtrace_silencers.rb
316
+ - spec/dummy/config/initializers/content_security_policy.rb
317
+ - spec/dummy/config/initializers/cookies_serializer.rb
318
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
319
+ - spec/dummy/config/initializers/inflections.rb
320
+ - spec/dummy/config/initializers/mime_types.rb
321
+ - spec/dummy/config/initializers/wrap_parameters.rb
322
+ - spec/dummy/config/locales/en.yml
323
+ - spec/dummy/config/puma.rb
324
+ - spec/dummy/config/routes.rb
325
+ - spec/dummy/config/spring.rb
326
+ - spec/dummy/config/storage.yml
327
+ - spec/dummy/db/schema.rb
328
+ - spec/dummy/lib/assets/.keep
329
+ - spec/dummy/log/.keep
330
+ - spec/dummy/public/404.html
331
+ - spec/dummy/public/422.html
332
+ - spec/dummy/public/500.html
333
+ - spec/dummy/public/apple-touch-icon-precomposed.png
334
+ - spec/dummy/public/apple-touch-icon.png
335
+ - spec/dummy/public/favicon.ico
336
+ - spec/dummy/tmp/development_secret.txt
337
+ - spec/fixtures/accounts.yml
338
+ - spec/fixtures/custom_primary_key_tasks.yml
339
+ - spec/fixtures/global_projects.yml
340
+ - spec/fixtures/projects.yml
341
+ - spec/helpers/tenant_helper_spec.rb
342
+ - spec/middlewares/test_tenant_middleware_spec.rb
343
+ - spec/models/model_extensions_spec.rb
180
344
  - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- .rvmrc
2
- *.gem
3
- .bundle
4
- Gemfile.lock
5
- pkg/*
6
- spec/*.sqlite3
7
- spec/*.log
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- before_install:
3
- - gem update bundler
4
- script: bundle exec rake spec
data/CHANGELOG.md DELETED
@@ -1,112 +0,0 @@
1
- 0.4.3
2
- -----
3
- * allow 'optional' relations
4
- * Sidekiq fixes
5
- * Replace all `before_filter` with `before_action` for Rails 5.1 compatibility
6
-
7
- 0.4.1
8
- ------
9
- * Removed (stale, no longer working) MongoDB support; moved code to separate branch
10
- * Added without_tenant option (see readme, thx duboff)
11
-
12
- 0.4.0
13
- ------
14
- * (Sub)domain lookup is no longer case insensitive
15
- * Added ability to use inverse_of (thx lowjoel)
16
- * Added ability to disable tenant checking for a block (thx duboff)
17
- * Allow for validation that associations belong to the tenant to reflect on associations which return an Array from `where` (thx ludamillion)
18
-
19
- 0.3.9
20
- -----
21
- * Added ability to configure a default tenant for testing purposes. (thx iangreenleaf)
22
- * AaT will now accept a string for a tenant_id (thx calebthompson)
23
- * Improvements to readme (thx stgeneral)
24
-
25
- 0.3.8
26
- -----
27
- * Added Mongoid compatibility [thx iangreenleaf]
28
-
29
- 0.3.7
30
- -----
31
- * Fix for proper handling of polymorphic associations (thx sol1dus)
32
- * Fix fefault scope to generate correct sql when using database prefix (thx IgorDobryn)
33
- * Added ability to specify a custom Primary Key (thx matiasdim)
34
- * Sidekiq 3.2.2+ no longer supports Ruby 1.9. Locking Sidekiq in gemspec at 3.2.1.
35
- * Update RSPEC to 3.0. Convert all specs (thx petergoldstein)
36
- * support sidekiq 3 interface (thx davekaro)
37
-
38
- 0.3.6
39
- -----
40
- * Added method `set_current_tenant_by_subdomain_or_domain` (thx preth00nker)
41
-
42
- 0.3.5
43
- -----
44
- * Fix to degredation introduced after 3.1 that prevented tenant_id from being set during initialization (thx jorgevaldivia)
45
-
46
- 0.3.4
47
- -----
48
- * Fix to a bug introduced in 0.3.2
49
-
50
- 0.3.3
51
- -----
52
- * Support user defined foreign keys on scoped models
53
-
54
- 0.3.2
55
- -----
56
- * correctly support nested models with has_many :through (thx dexion)
57
- * Support 'www.subdomain.example.com' (thx wtfiwtz)
58
- * Support setting `tenant_id` on scoped models if the `tenant_id` is nil (thx Matt Wilson)
59
-
60
- 0.3.1
61
- -----
62
- * Added support for Rails 4
63
-
64
- 0.3.0
65
- -----
66
- * You can now raise an exception if a query on a scope model is made without a tenant set. Adding an initializer that sets config.require_tenant to true will accomplish this. See readme for more details.
67
- * `ActsAsTenant.with_tenant` will now return the value of the block it evaluates instead of the original tenant. The original tenant is restored automatically.
68
- * acts_as_tenant now raises standard errors which can be caught individually.
69
- * `set_current_tenant_to`, which was deprecated some versions ago and could lead to weird errors, has been removed.
70
-
71
-
72
- 0.2.9
73
- -----
74
- * Added support for many-to-many associations (thx Nucleoid)
75
-
76
- 0.2.8
77
- -----
78
- * Added dependencies to gemspec (thx aaronrenner)
79
- * Added the `ActsAsTenant.with_tenant` block method (see readme) (thx aaronrenner)
80
- * Acts_as_Tenant is now thread safe (thx davide)
81
-
82
- 0.2.7
83
- -----
84
- * Changed the interface for passing in the current_tenant manually in the controller. `set_current_tenant_to` has been deprecated and replaced by `set_current_tenant_through_filter` declaration and the `set_current_tenant` method. See readme for details.
85
-
86
- 0.2.6
87
- -----
88
- * Fixed a bug with resolving the tenant model name (thx devton!)
89
- * Added support for using relations: User.create(:account => Account.first) now works, while it wouldn't before (thx bnmrrs)
90
-
91
- 0.2.5
92
- -----
93
- * Added Rails 3.2 compatibility (thx nickveys!)
94
-
95
- 0.2.4
96
- -----
97
- * Added correct handling of child models that do not have their parent set (foreign key == nil)
98
-
99
-
100
- 0.2.3
101
- -----
102
- * Added support for models that declare a has_one relationships, these would error out in the previous versions.
103
-
104
-
105
- 0.2.2
106
- -----
107
- * Enhancements
108
- * Added support for aliased associations ( belongs_to :something, :class_name => 'SomethingElse'). In previous version these would raise an 'uninitialized constant' error.
109
-
110
- 0.2.1
111
- -----
112
- * Initial release
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in acts_as_tenant.gemspec
4
- gemspec
data/_config.yml DELETED
@@ -1 +0,0 @@
1
- theme: jekyll-theme-tactile
@@ -1,32 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "acts_as_tenant/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "acts_as_tenant"
7
- s.version = ActsAsTenant::VERSION
8
- s.authors = ["Erwin Matthijssen"]
9
- s.email = ["erwin.matthijssen@gmail.com"]
10
- s.homepage = "http://www.rollcallapp.com/blog"
11
- s.summary = %q{Add multi-tenancy to Rails applications using a shared db strategy}
12
- s.description = %q{Integrates multi-tenancy into a Rails application in a convenient and out-of-your way manner}
13
-
14
- s.rubyforge_project = "acts_as_tenant"
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.require_paths = ["lib"]
20
-
21
- s.add_runtime_dependency('request_store', '>= 1.0.5')
22
- s.add_dependency('rails','>= 4.0')
23
- #s.add_dependency('request_store', '>= 1.0.5')
24
-
25
- s.add_development_dependency('rspec', '>=3.0')
26
- s.add_development_dependency('rspec-rails')
27
- s.add_development_dependency('database_cleaner', '~> 1.5.3')
28
- s.add_development_dependency('sqlite3')
29
- #s.add_development_dependency('mongoid', '~> 4.0')
30
-
31
- s.add_development_dependency('sidekiq', '3.2.1')
32
- end
data/docs/blog_post.md DELETED
@@ -1,67 +0,0 @@
1
- <h2> Adding multi-tenancy to your Rails app: acts_as_tenant </h2>
2
- Roll Call is implemented as a multi-tenant application: each user gets their own instance of the app, content is strictly scoped to a user&#8217;s instance. In Rails, this can be achieved in various ways. Guy Naor did a great job of diving into the pros and cons of each option in his <a href="http://confreaks.net/videos/111-aac2009-writing-multi-tenant-applications-in-rails">2009 Acts As Conference talk</a>. If you are doing multi-tenancy in Rails, you should watch his video.</p>
3
- <p>With a multi-db or multi-schema approach, you only deal with the multi-tenancy-aspect in a few specific spots in your app (Jerod Santo recently wrote an excellent post on implementing a <a href="http://blog.jerodsanto.net/2011/07/building-multi-tenant-rails-apps-with-postgresql-schemas/">multi-schema strategy</a>). Compared to the previous two strategies, a <strong>shared database</strong> strategy has the downside that the &#8216;multi-tenancy&#8217;-logic is something you need to actively be aware of and manage in almost every part of your app.</p>
4
- <h4>Using a Shared Database strategy is alot of work!</h4>
5
- <p>For various other reasons we opted for a <strong>shared database</strong> strategy. However, for us the prospect of dealing with the multi-tenancy-logic throughout our app, was not appealing. Worse, we run the risk of accidently exposing content of one tenant to another one, if we mismanage this logic. While researching this topic I noticed there are no real ready made solutions available that get you on your way, <a href="http://github.com/wireframe/multitenant">Ryan Sonnek</a> wrote his &#8216;multitenant&#8217; gem and <a href="http://github.com/mconnell/multi_tenant">Mark Connel</a> did the same. Neither of these solution seemed &#8220;finished&#8221; to us. So, we wrote our own implementation.</p>
6
- <h4>First, how does multi-tenancy with a shared database strategy work</h4>
7
- <p>A shared database strategy manages the multi-tenancy-logic through Rails associations. A tenant is represented by an object, for example an <code>Account</code>. All other objects are associated with a tenant: <code>belongs_to :account</code>. Each request starts with finding the <code>@current_account</code>. After that, each find is scoped through the tenant object: <code>current_account.projects.all</code>. This has to be remembered everywhere: in model method declarations and in controller actions. Otherwise, you&#8217;re exposing content of other tenants.</p>
8
- <p>In addition, you have to actively babysit other parts of your app: <code>validates_uniqueness_of</code> requires you to scope it to the current tenant. You also have to protect agaist all sorts of form-injections that could allow one tenant to gain access or temper with the content of another tenant (see <a href="http://www.slideshare.net/tardate/multitenancy-with-rails">Paul Gallaghers</a> presentation for more on these dangers).</p>
9
- <h4>Enter acts_as_tenant</h4>
10
- <p>I wanted to implement all the concerns above in an easy to manage, out of the way fashion. We should be able to add a single declaration to our model and that should implement:</p>
11
- <ol>
12
- <li>scoping all searches to the current <code>Account</code></li>
13
- <li>scoping the uniqueness validator to the current <code>Account</code></li>
14
- <li>protecting against various nastiness trying to circumvent the scoping.</li>
15
- </ol>
16
- <p>The result is <code>acts_as_tenant</code> (<a href="https://github.com/ErwinM/acts_as_tenant">github</a>), a rails gem that will add multi tenancy using a shared database to your rails app in an out-of-your way fashion.</p>
17
- <p>In the <span class="caps">README</span>, you will find more information on using <code>acts_as_tenant</code> in your projects, so we&#8217;ll give you a high-level overview here. Let&#8217;s suppose that you have an app to which you want to add multi tenancy, tenants are represented by the <code>Account</code> model and <code>Project</code> is one of the models that should be scoped by tenant:</p>
18
-
19
- ```ruby
20
- class Addaccounttoproject < ActiveRecord::Migration
21
- def change
22
- add_column :projects, :account_id, :integer
23
- end
24
- end
25
-
26
- class Project < ActiveRecord::Base
27
- acts_as_tenant(:account)
28
- validates_uniqueness_to_tenant :name
29
- end
30
- ```
31
- What does adding these two methods accomplish:
32
- <ol>
33
- <li>it ensures every search on the project model will be scoped to the current tenant,</li>
34
- <li>it adds validation for every association confirming the associated object does indeed belong to the current tenant,</li>
35
- <li>it validates the uniqueness of `:name` to the current tenant,</li>
36
- <li>it implements a bunch of safeguards preventing all kinds of nastiness from exposing other tenants data (mainly form-injection attacks).</li>
37
- </ol>
38
- <p>Ofcourse, all the above assumes `acts_as_tenant` actually knows who the current tenant is. Two strategies are implemented to help with this.</p>
39
- <p><strong>Using the subdomain to workout the current tenant</strong></p>
40
-
41
- ```ruby
42
- class ApplicationController < ActionController::Base
43
- set_current_tenant_by_subdomain(:account, :subdomain)
44
- end
45
- ```
46
- <p>Adding the above method to your `application_controller` tells `acts_as_tenant`:</p>
47
- <ol>
48
- <li>the current tenant should be found based on the subdomain (e.g. account1.myappdomain.com),</li>
49
- <li>tenants are represented by the `Account`-model and</li>
50
- <li>the `Account` model has a column named `subdomain` that should be used the lookup the current account, using the current subdomain.</li>
51
- </ol>
52
- <p><strong>Passing the current account to acts_as_tenant yourself</strong></p>
53
-
54
- ```ruby
55
- class ApplicationController < ActionController::Base
56
- current_account = Account.method_to_find_the_current_account
57
- set_current_tenant_to(current_account)
58
- end
59
- ```
60
- <p>`Acts_as_tenant` also adds a handy helper to your controllers `current_tenant`, containing the current tenant object.</p>
61
- <h4>Great! Anything else I should know? A few caveats:</h4>
62
- <ul>
63
- <li>scoping of models *only* works if `acts_as_tenant` has a current_tenant available. If you do not set one by one of the methods described above, *no scope* will be applied!</li>
64
- <li>for validating uniqueness within a tenant scope you must use the `validates_uniqueness_to_tenant`method. This method takes all the options the regular `validates_uniqueness_of` method takes.</li>
65
- <li>it is probably best to add the `acts_as_tenant` declaration after any other `default_scope` declarations you add to a model (I am not exactly sure how rails 3 handles the chaining. If someone can enlighten me, thanks!).</li>
66
- </ul>
67
- <p>We have been testing <a href="https://github.com/ErwinM/acts_as_tenant">acts_as_tenant</a> within Roll Call during recent weeks and it seems to be behaving well. Having said that, we welcome any feedback. This is my first real attempt at a plugin and the possibility of various improvements is almost a given.</p>
data/rails/init.rb DELETED
@@ -1,2 +0,0 @@
1
- ActiveRecord::Base.send(:include, ActsAsTenant::ModelExtensions)
2
- ActionController::Base.extend ActsAsTenant::ControllerExtensions
@@ -1,22 +0,0 @@
1
- require 'rails/all'
2
- require 'database_cleaner'
3
- require 'yaml'
4
-
5
- dbconfig = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'database.yml')))
6
- ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
7
- ActiveRecord::Base.establish_connection(dbconfig[ENV['DB'] || 'sqlite'])
8
-
9
- RSpec.configure do |config|
10
- config.before(:suite) do
11
- DatabaseCleaner[:active_record].strategy = :transaction
12
- DatabaseCleaner[:active_record].clean_with(:truncation)
13
- end
14
-
15
- config.before(:each) do
16
- DatabaseCleaner[:active_record].start
17
- end
18
-
19
- config.after(:each) do
20
- DatabaseCleaner[:active_record].clean
21
- end
22
- end