acts_as_tenant 0.4.0 → 0.5.0

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 +90 -26
  3. data/Rakefile +5 -14
  4. data/lib/acts_as_tenant.rb +114 -12
  5. data/lib/acts_as_tenant/configuration.rb +6 -19
  6. data/lib/acts_as_tenant/controller_extensions.rb +11 -56
  7. data/lib/acts_as_tenant/controller_extensions/filter.rb +13 -0
  8. data/lib/acts_as_tenant/controller_extensions/subdomain.rb +20 -0
  9. data/lib/acts_as_tenant/controller_extensions/subdomain_or_domain.rb +20 -0
  10. data/lib/acts_as_tenant/errors.rb +3 -4
  11. data/lib/acts_as_tenant/model_extensions.rb +62 -107
  12. data/lib/acts_as_tenant/sidekiq.rb +16 -8
  13. data/lib/acts_as_tenant/tenant_helper.rb +7 -0
  14. data/lib/acts_as_tenant/test_tenant_middleware.rb +15 -0
  15. data/lib/acts_as_tenant/version.rb +1 -1
  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/controllers/filter_spec.rb +28 -0
  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/manager.rb +4 -0
  45. data/spec/dummy/app/models/polymorphic_tenant_comment.rb +5 -0
  46. data/spec/dummy/app/models/project.rb +8 -0
  47. data/spec/dummy/app/models/task.rb +7 -0
  48. data/spec/dummy/app/models/unique_task.rb +5 -0
  49. data/spec/dummy/app/models/unscoped_model.rb +3 -0
  50. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  51. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  52. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  53. data/spec/dummy/bin/rails +4 -0
  54. data/spec/dummy/bin/rake +4 -0
  55. data/spec/dummy/bin/setup +33 -0
  56. data/spec/dummy/config.ru +5 -0
  57. data/spec/dummy/config/application.rb +19 -0
  58. data/spec/dummy/config/boot.rb +5 -0
  59. data/spec/dummy/config/cable.yml +10 -0
  60. data/spec/dummy/config/database.yml +19 -0
  61. data/spec/dummy/config/environment.rb +5 -0
  62. data/spec/dummy/config/environments/development.rb +62 -0
  63. data/spec/dummy/config/environments/production.rb +112 -0
  64. data/spec/dummy/config/environments/test.rb +49 -0
  65. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  66. data/spec/dummy/config/initializers/assets.rb +12 -0
  67. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  68. data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
  69. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  70. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  71. data/spec/dummy/config/initializers/inflections.rb +16 -0
  72. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  73. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  74. data/spec/dummy/config/locales/en.yml +40 -0
  75. data/spec/dummy/config/puma.rb +38 -0
  76. data/spec/dummy/config/routes.rb +4 -0
  77. data/spec/dummy/config/spring.rb +6 -0
  78. data/spec/dummy/config/storage.yml +34 -0
  79. data/spec/dummy/db/schema.rb +84 -0
  80. data/spec/dummy/lib/assets/.keep +0 -0
  81. data/spec/dummy/log/.keep +0 -0
  82. data/spec/dummy/public/404.html +67 -0
  83. data/spec/dummy/public/422.html +67 -0
  84. data/spec/dummy/public/500.html +66 -0
  85. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  86. data/spec/dummy/public/apple-touch-icon.png +0 -0
  87. data/spec/dummy/public/favicon.ico +0 -0
  88. data/spec/dummy/tmp/development_secret.txt +1 -0
  89. data/spec/fixtures/accounts.yml +10 -0
  90. data/spec/fixtures/custom_primary_key_tasks.yml +2 -0
  91. data/spec/fixtures/global_projects.yml +13 -0
  92. data/spec/fixtures/projects.yml +10 -0
  93. data/spec/helpers/tenant_helper_spec.rb +16 -0
  94. data/spec/middlewares/test_tenant_middleware_spec.rb +86 -0
  95. data/spec/models/model_extensions_spec.rb +383 -0
  96. data/spec/spec_helper.rb +10 -15
  97. metadata +196 -54
  98. data/.gitignore +0 -7
  99. data/.travis.yml +0 -6
  100. data/CHANGELOG.md +0 -101
  101. data/Gemfile +0 -4
  102. data/acts_as_tenant.gemspec +0 -33
  103. data/rails/init.rb +0 -2
  104. data/spec/active_record_helper.rb +0 -22
  105. data/spec/active_record_models.rb +0 -109
  106. data/spec/acts_as_tenant/model_extensions_spec.rb +0 -394
  107. data/spec/acts_as_tenant/tenant_by_filter_spec.rb +0 -33
  108. data/spec/acts_as_tenant/tenant_by_subdomain_or_domain.rb +0 -46
  109. data/spec/acts_as_tenant/tenant_by_subdomain_spec.rb +0 -32
  110. data/spec/database.yml +0 -3
  111. data/spec/mongoid.yml +0 -6
  112. data/spec/mongoid_helper.rb +0 -23
  113. data/spec/mongoid_models.rb +0 -81
@@ -0,0 +1,383 @@
1
+ require "spec_helper"
2
+
3
+ describe ActsAsTenant do
4
+ let(:account) { accounts(:foo) }
5
+
6
+ it "can set the current tenant" do
7
+ ActsAsTenant.current_tenant = :foo
8
+ expect(ActsAsTenant.current_tenant).to eq(:foo)
9
+ end
10
+
11
+ it "is_scoped_as_tenant should return the correct value when true" do
12
+ expect(Project.respond_to?(:scoped_by_tenant?)).to eq(true)
13
+ end
14
+
15
+ it "is_scoped_as_tenant should return the correct value when false" do
16
+ expect(UnscopedModel.respond_to?(:scoped_by_tenant?)).to eq(false)
17
+ end
18
+
19
+ it "tenant_id should be immutable, if already set" do
20
+ project = account.projects.create!(name: "bar")
21
+ expect { project.account_id = account.id + 1 }.to raise_error(ActsAsTenant::Errors::TenantIsImmutable)
22
+ end
23
+
24
+ it "setting tenant_id to the same value should not error" do
25
+ project = account.projects.create!(name: "bar")
26
+ expect { project.account_id = account.id }.not_to raise_error
27
+ end
28
+
29
+ it "setting tenant_id to a string with same to_i value should not error" do
30
+ project = account.projects.create!(name: "bar")
31
+ expect { project.account_id = account.id.to_s }.not_to raise_error
32
+ end
33
+
34
+ it "tenant_id should be mutable, if not already set" do
35
+ project = projects(:without_account)
36
+ expect(project.account_id).to be_nil
37
+ expect { project.account = account }.not_to raise_error
38
+ end
39
+
40
+ it "tenant_id should auto populate after initialization" do
41
+ ActsAsTenant.current_tenant = account
42
+ expect(Project.new.account_id).to eq(account.id)
43
+ end
44
+
45
+ it "handles custom foreign_key on tenant model" do
46
+ ActsAsTenant.current_tenant = account
47
+ custom_foreign_key_task = CustomForeignKeyTask.create!(name: "foo")
48
+ expect(custom_foreign_key_task.account).to eq(account)
49
+ end
50
+
51
+ it "handles custom primary_key on tenant model" do
52
+ ActsAsTenant.current_tenant = account
53
+ custom_primary_key_task = CustomPrimaryKeyTask.create!
54
+ expect(custom_primary_key_task.account).to eq(account)
55
+ expect(CustomPrimaryKeyTask.count).to eq(1)
56
+ end
57
+
58
+ it "should correctly increment and decrement the tenants counter_cache column" do
59
+ ActsAsTenant.current_tenant = account
60
+ project = CustomCounterCacheTask.create!(name: "bar")
61
+ expect(account.reload.projects_count).to eq(1)
62
+ project.destroy
63
+ expect(account.reload.projects_count).to eq(0)
64
+ end
65
+
66
+ it "does not cache account association" do
67
+ project = account.projects.first
68
+ ActsAsTenant.current_tenant = account
69
+ expect(project.account.name).to eq(account.name)
70
+ account.update!(name: "Acme")
71
+ expect(project.account.name).to eq("Acme")
72
+ end
73
+
74
+ it "Querying the tenant from a scoped model without a tenant set" do
75
+ expect(projects(:foo).account).to_not be_nil
76
+ end
77
+
78
+ it "Querying the tenant from a scoped model with a tenant set" do
79
+ ActsAsTenant.current_tenant = account
80
+ expect(projects(:foo).account).to eq(accounts(:foo))
81
+ expect(projects(:bar).account).to eq(accounts(:bar))
82
+ end
83
+
84
+ describe "scoping models" do
85
+ it "should scope Project.all to the current tenant if set" do
86
+ ActsAsTenant.current_tenant = account
87
+ expect(Project.count).to eq(account.projects.count)
88
+ expect(Project.all).to eq(account.projects)
89
+ end
90
+
91
+ it "should allow unscoping" do
92
+ ActsAsTenant.current_tenant = account
93
+ expect(Project.unscoped.count).to be > account.projects.count
94
+ end
95
+
96
+ it "returns nothing with unsaved tenant" do
97
+ ActsAsTenant.current_tenant = Account.new
98
+ expect(Project.all.count).to eq(0)
99
+ end
100
+ end
101
+
102
+ describe "A tenant model with global records" do
103
+ before do
104
+ ActsAsTenant.current_tenant = account
105
+ end
106
+
107
+ it "should return global and tenant projects" do
108
+ expect(GlobalProject.count).to eq(GlobalProject.unscoped.where(account: [nil, account]).count)
109
+ end
110
+
111
+ it "returns global records with unsaved tenant" do
112
+ ActsAsTenant.current_tenant = Account.new
113
+ expect(GlobalProject.all.count).to eq(GlobalProject.unscoped.where(account: [nil]).count)
114
+ end
115
+
116
+ context "should validate tenant records against global & tenant records" do
117
+ it "global records are valid" do
118
+ expect(global_projects(:global).valid?).to be(true)
119
+ end
120
+
121
+ it "allows separate global and tenant records" do
122
+ expect(GlobalProject.new(name: "foo new").valid?).to be(true)
123
+ end
124
+
125
+ it "is invalid with with duplicate tenant records" do
126
+ expect(GlobalProject.new(name: "global foo").valid?).to be(false)
127
+ end
128
+
129
+ it "is invalid if tenant record conflicts with global record" do
130
+ expect(GlobalProject.new(name: "global").valid?).to be(false)
131
+ end
132
+ end
133
+
134
+ it "should add the model to ActsAsTenant.models_with_global_records" do
135
+ expect(ActsAsTenant.models_with_global_records.include?(GlobalProject)).to be_truthy
136
+ expect(ActsAsTenant.models_with_global_records.include?(Project)).to be_falsy
137
+ end
138
+ end
139
+
140
+ # Associations
141
+ context "Associations should be correctly scoped by current tenant" do
142
+ before do
143
+ @project = account.projects.create!(name: "foobar")
144
+
145
+ # the next line should normally be (nearly) impossible: a task assigned to a tenant project,
146
+ # but the task has no tenant assigned
147
+ @task1 = Task.create!(name: "no_tenant", project: @project)
148
+
149
+ ActsAsTenant.current_tenant = account
150
+ @task2 = @project.tasks.create!(name: "baz")
151
+
152
+ @project.reload
153
+ end
154
+
155
+ it "should correctly set the tenant on the task created with current_tenant set" do
156
+ expect(@task2.account).to eq(account)
157
+ end
158
+
159
+ it "should filter out the non-tenant task from the project" do
160
+ expect(@project.tasks.length).to eq(1)
161
+ end
162
+ end
163
+
164
+ it "associations can only be made with in-scope objects" do
165
+ project1 = accounts(:bar).projects.create!(name: "inaccessible_project")
166
+ ActsAsTenant.current_tenant = account
167
+
168
+ project2 = Project.create!(name: "accessible_project")
169
+ task = project2.tasks.create!(name: "bar")
170
+
171
+ expect(task.update(project_id: project1.id)).to eq(false)
172
+ end
173
+
174
+ it "can create and save an AaT-enabled child without it having a parent" do
175
+ ActsAsTenant.current_tenant = account
176
+ expect(Task.new(name: "bar").valid?).to eq(true)
177
+ end
178
+
179
+ it "should be possible to use aliased associations" do
180
+ expect(AliasedTask.create(name: "foo", project_alias: @project2).valid?).to eq(true)
181
+ end
182
+
183
+ describe "It should be possible to use associations with foreign_key from polymorphic" do
184
+ it "tenanted objects have a polymorphic association" do
185
+ ActsAsTenant.current_tenant = account
186
+ expect { Comment.create!(commentable: account.projects.first) }.not_to raise_error
187
+ end
188
+
189
+ context "tenant is polymorphic" do
190
+ before do
191
+ @project = Project.create!(name: "polymorphic project")
192
+ ActsAsTenant.current_tenant = @project
193
+ @comment = PolymorphicTenantComment.new(account: account)
194
+ end
195
+
196
+ it "populates commentable_type with the current tenant" do
197
+ expect(@comment.polymorphic_tenant_commentable_id).to eql(@project.id)
198
+ expect(@comment.polymorphic_tenant_commentable_type).to eql(@project.class.to_s)
199
+ end
200
+
201
+ context "with another type of tenant, same id" do
202
+ before do
203
+ @comment.save!
204
+ @article = Article.create!(id: @project.id, title: "article title")
205
+ @comment_on_article = @article.polymorphic_tenant_comments.create!
206
+ end
207
+
208
+ it "correctly scopes to the current tenant type" do
209
+ expect(@comment_on_article).to be_persisted
210
+ expect(@comment).to be_persisted
211
+ expect(PolymorphicTenantComment.count).to eql(1)
212
+ expect(PolymorphicTenantComment.all.first.attributes).to eql(@comment.attributes)
213
+ end
214
+ end
215
+ end
216
+ end
217
+
218
+ # Additional default_scopes
219
+ it "should apply both the tenant scope and the user defined default_scope, including :order" do
220
+ project1 = Project.create!(name: "inaccessible")
221
+ Task.create!(name: "no_tenant", project: project1)
222
+
223
+ ActsAsTenant.current_tenant = account
224
+ project2 = Project.create!(name: "accessible")
225
+ task2 = project2.tasks.create!(name: "bar")
226
+ task3 = project2.tasks.create!(name: "baz")
227
+ task4 = project2.tasks.create!(name: "foo")
228
+ project2.tasks.create!(name: "foobar", completed: true)
229
+
230
+ tasks = Task.all
231
+
232
+ expect(tasks.length).to eq(3)
233
+ expect(tasks).to eq([task2, task3, task4])
234
+ end
235
+
236
+ # Validates_uniqueness
237
+ context "When using validates_uniqueness_to_tenant in a aat model" do
238
+ before do
239
+ @name = "existing_name"
240
+ ActsAsTenant.current_tenant = account
241
+ Project.create!(name: @name)
242
+ end
243
+
244
+ it "should not be possible to create a duplicate within the same tenant" do
245
+ expect(Project.new(name: @name).valid?).to eq(false)
246
+ end
247
+
248
+ it "should be possible to create a duplicate in another tenant" do
249
+ ActsAsTenant.current_tenant = accounts(:bar)
250
+ expect(Project.create(name: @name).valid?).to eq(true)
251
+ end
252
+ end
253
+
254
+ it "handles user defined scopes" do
255
+ UniqueTask.create!(name: "foo", user_defined_scope: "unique_scope")
256
+ expect(UniqueTask.create(name: "foo", user_defined_scope: "another_scope")).to be_valid
257
+ expect(UniqueTask.create(name: "foo", user_defined_scope: "unique_scope")).not_to be_valid
258
+ end
259
+
260
+ context "When using validates_uniqueness_of in a NON-aat model" do
261
+ it "should not be possible to create duplicates" do
262
+ UnscopedModel.create!(name: "foo")
263
+ expect(UnscopedModel.create(name: "foo").valid?).to eq(false)
264
+ end
265
+ end
266
+
267
+ # ::with_tenant
268
+ describe "::with_tenant" do
269
+ it "should set current_tenant to the specified tenant inside the block" do
270
+ ActsAsTenant.with_tenant(account) do
271
+ expect(ActsAsTenant.current_tenant).to eq(account)
272
+ end
273
+ end
274
+
275
+ it "should reset current_tenant to the previous tenant once exiting the block" do
276
+ ActsAsTenant.current_tenant = account
277
+ ActsAsTenant.with_tenant(accounts(:bar)) {}
278
+ expect(ActsAsTenant.current_tenant).to eq(account)
279
+ end
280
+
281
+ it "should return the value of the block" do
282
+ ActsAsTenant.current_tenant = account
283
+ value = ActsAsTenant.with_tenant(accounts(:bar)) { "something" }
284
+ expect(value).to eq "something"
285
+ end
286
+
287
+ it "should raise an error when no block is provided" do
288
+ expect { ActsAsTenant.with_tenant(nil) }.to raise_error(ArgumentError, /block required/)
289
+ end
290
+ end
291
+
292
+ describe "::without_tenant" do
293
+ it "should set current_tenant to nil inside the block" do
294
+ ActsAsTenant.without_tenant do
295
+ expect(ActsAsTenant.current_tenant).to be_nil
296
+ end
297
+ end
298
+
299
+ it "should set current_tenant to nil even if default_tenant is set" do
300
+ old_default_tenant = ActsAsTenant.default_tenant
301
+ ActsAsTenant.default_tenant = Account.create!(name: "foo")
302
+ ActsAsTenant.without_tenant do
303
+ expect(ActsAsTenant.current_tenant).to be_nil
304
+ end
305
+ ensure
306
+ ActsAsTenant.default_tenant = old_default_tenant
307
+ end
308
+
309
+ it "should reset current_tenant to the previous tenant once exiting the block" do
310
+ ActsAsTenant.current_tenant = account
311
+ ActsAsTenant.without_tenant {}
312
+ expect(ActsAsTenant.current_tenant).to eq(account)
313
+ end
314
+
315
+ it "should return the value of the block" do
316
+ value = ActsAsTenant.without_tenant { "something" }
317
+ expect(value).to eq "something"
318
+ end
319
+
320
+ it "should raise an error when no block is provided" do
321
+ expect { ActsAsTenant.without_tenant }.to raise_error(ArgumentError, /block required/)
322
+ end
323
+ end
324
+
325
+ # Tenant required
326
+ context "tenant required" do
327
+ before do
328
+ account.projects.create!(name: "foobar")
329
+ allow(ActsAsTenant.configuration).to receive_messages(require_tenant: true)
330
+ end
331
+
332
+ it "should raise an error when no tenant is provided" do
333
+ expect { Project.all }.to raise_error(ActsAsTenant::Errors::NoTenantSet)
334
+ end
335
+
336
+ it "should not raise an error when no tenant is provided" do
337
+ expect { ActsAsTenant.without_tenant { Project.all } }.to_not raise_error
338
+ end
339
+ end
340
+
341
+ context "no tenant required" do
342
+ it "should not raise an error when no tenant is provided" do
343
+ expect { Project.all }.to_not raise_error
344
+ end
345
+ end
346
+
347
+ describe "ActsAsTenant.default_tenant=" do
348
+ after(:each) do
349
+ ActsAsTenant.default_tenant = nil
350
+ end
351
+
352
+ it "provides current_tenant" do
353
+ ActsAsTenant.default_tenant = account
354
+ expect(ActsAsTenant.current_tenant).to eq(account)
355
+ end
356
+
357
+ it "can be overridden by assignment" do
358
+ ActsAsTenant.default_tenant = account
359
+ ActsAsTenant.current_tenant = accounts(:bar)
360
+ expect(ActsAsTenant.current_tenant).to eq(accounts(:bar))
361
+ end
362
+
363
+ it "can be overridden by with_tenant" do
364
+ ActsAsTenant.default_tenant = account
365
+ ActsAsTenant.with_tenant accounts(:bar) do
366
+ expect(ActsAsTenant.current_tenant).to eq(accounts(:bar))
367
+ end
368
+ expect(ActsAsTenant.current_tenant).to eq(account)
369
+ end
370
+
371
+ it "doesn't override existing current_tenant" do
372
+ ActsAsTenant.current_tenant = accounts(:bar)
373
+ ActsAsTenant.default_tenant = account
374
+ expect(ActsAsTenant.current_tenant).to eq(accounts(:bar))
375
+ end
376
+
377
+ it "survives request resets" do
378
+ ActsAsTenant.default_tenant = account
379
+ RequestStore.clear!
380
+ expect(ActsAsTenant.current_tenant).to eq(account)
381
+ end
382
+ end
383
+ end
@@ -1,24 +1,19 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
3
 
4
- $orm = ENV["ORM"] || "active_record"
5
- require "#{$orm}_helper"
4
+ require_relative "../spec/dummy/config/environment"
5
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../spec/dummy/db/migrate", __dir__)]
6
+ ActiveRecord::Migration.maintain_test_schema!
6
7
 
7
- require 'rspec/rails'
8
- require 'acts_as_tenant'
8
+ require "rspec/rails"
9
9
 
10
10
  RSpec.configure do |config|
11
11
  config.after(:each) do
12
12
  ActsAsTenant.current_tenant = nil
13
13
  end
14
-
15
- config.infer_base_class_for_anonymous_controllers = true
16
- end
17
14
 
18
- # Setup a test app
19
- module Rollcall
20
- class Application < Rails::Application; end
15
+ config.fixture_path = "spec/fixtures"
16
+ config.global_fixtures = :all
17
+ config.use_transactional_fixtures = true
18
+ config.infer_base_class_for_anonymous_controllers = true
21
19
  end
22
-
23
- Rollcall::Application.config.secret_token = '1234567890123456789012345678901234567890'
24
- Rollcall::Application.config.secret_key_base = '1234567890123456789012345678901234567890'
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.0
4
+ version: 0.5.0
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: 2016-08-14 00:00:00.000000000 Z
12
+ date: 2020-11-18 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: '3.1'
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: '3.1'
41
+ version: '5.2'
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: rspec
43
44
  requirement: !ruby/object:Gem::Requirement
@@ -67,102 +68,176 @@ dependencies:
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  - !ruby/object:Gem::Dependency
70
- name: database_cleaner
71
+ name: sqlite3
71
72
  requirement: !ruby/object:Gem::Requirement
72
73
  requirements:
73
- - - "~>"
74
+ - - ">="
74
75
  - !ruby/object:Gem::Version
75
- version: 1.3.0
76
+ version: '0'
76
77
  type: :development
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
- - - "~>"
81
+ - - ">="
81
82
  - !ruby/object:Gem::Version
82
- version: 1.3.0
83
+ version: '0'
83
84
  - !ruby/object:Gem::Dependency
84
- name: sqlite3
85
+ name: sidekiq
85
86
  requirement: !ruby/object:Gem::Requirement
86
87
  requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '6.1'
87
91
  - - ">="
88
92
  - !ruby/object:Gem::Version
89
- version: '0'
93
+ version: 6.1.2
90
94
  type: :development
91
95
  prerelease: false
92
96
  version_requirements: !ruby/object:Gem::Requirement
93
97
  requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '6.1'
94
101
  - - ">="
95
102
  - !ruby/object:Gem::Version
96
- version: '0'
103
+ version: 6.1.2
97
104
  - !ruby/object:Gem::Dependency
98
- name: mongoid
105
+ name: standard
99
106
  requirement: !ruby/object:Gem::Requirement
100
107
  requirements:
101
- - - "~>"
108
+ - - ">="
102
109
  - !ruby/object:Gem::Version
103
- version: '4.0'
110
+ version: '0'
104
111
  type: :development
105
112
  prerelease: false
106
113
  version_requirements: !ruby/object:Gem::Requirement
107
114
  requirements:
108
- - - "~>"
115
+ - - ">="
109
116
  - !ruby/object:Gem::Version
110
- version: '4.0'
117
+ version: '0'
111
118
  - !ruby/object:Gem::Dependency
112
- name: sidekiq
119
+ name: appraisal
113
120
  requirement: !ruby/object:Gem::Requirement
114
121
  requirements:
115
- - - '='
122
+ - - ">="
116
123
  - !ruby/object:Gem::Version
117
- version: 3.2.1
124
+ version: '0'
118
125
  type: :development
119
126
  prerelease: false
120
127
  version_requirements: !ruby/object:Gem::Requirement
121
128
  requirements:
122
- - - '='
129
+ - - ">="
123
130
  - !ruby/object:Gem::Version
124
- version: 3.2.1
131
+ version: '0'
125
132
  description: Integrates multi-tenancy into a Rails application in a convenient and
126
133
  out-of-your way manner
127
134
  email:
128
135
  - erwin.matthijssen@gmail.com
136
+ - excid3@gmail.com
129
137
  executables: []
130
138
  extensions: []
131
139
  extra_rdoc_files: []
132
140
  files:
133
- - ".gitignore"
134
- - ".travis.yml"
135
- - CHANGELOG.md
136
- - Gemfile
137
141
  - MIT-LICENSE
138
142
  - README.md
139
143
  - Rakefile
140
- - acts_as_tenant.gemspec
141
144
  - lib/acts_as_tenant.rb
142
145
  - lib/acts_as_tenant/configuration.rb
143
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
144
150
  - lib/acts_as_tenant/errors.rb
145
151
  - lib/acts_as_tenant/model_extensions.rb
146
152
  - lib/acts_as_tenant/sidekiq.rb
153
+ - lib/acts_as_tenant/tenant_helper.rb
154
+ - lib/acts_as_tenant/test_tenant_middleware.rb
147
155
  - lib/acts_as_tenant/version.rb
148
- - rails/init.rb
149
- - spec/active_record_helper.rb
150
- - spec/active_record_models.rb
151
156
  - spec/acts_as_tenant/configuration_spec.rb
152
- - spec/acts_as_tenant/model_extensions_spec.rb
153
157
  - spec/acts_as_tenant/sidekiq_spec.rb
154
- - spec/acts_as_tenant/tenant_by_filter_spec.rb
155
- - spec/acts_as_tenant/tenant_by_subdomain_or_domain.rb
156
- - spec/acts_as_tenant/tenant_by_subdomain_spec.rb
157
- - spec/database.yml
158
- - spec/mongoid.yml
159
- - spec/mongoid_helper.rb
160
- - spec/mongoid_models.rb
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/manager.rb
185
+ - spec/dummy/app/models/polymorphic_tenant_comment.rb
186
+ - spec/dummy/app/models/project.rb
187
+ - spec/dummy/app/models/task.rb
188
+ - spec/dummy/app/models/unique_task.rb
189
+ - spec/dummy/app/models/unscoped_model.rb
190
+ - spec/dummy/app/views/layouts/application.html.erb
191
+ - spec/dummy/app/views/layouts/mailer.html.erb
192
+ - spec/dummy/app/views/layouts/mailer.text.erb
193
+ - spec/dummy/bin/rails
194
+ - spec/dummy/bin/rake
195
+ - spec/dummy/bin/setup
196
+ - spec/dummy/config.ru
197
+ - spec/dummy/config/application.rb
198
+ - spec/dummy/config/boot.rb
199
+ - spec/dummy/config/cable.yml
200
+ - spec/dummy/config/database.yml
201
+ - spec/dummy/config/environment.rb
202
+ - spec/dummy/config/environments/development.rb
203
+ - spec/dummy/config/environments/production.rb
204
+ - spec/dummy/config/environments/test.rb
205
+ - spec/dummy/config/initializers/application_controller_renderer.rb
206
+ - spec/dummy/config/initializers/assets.rb
207
+ - spec/dummy/config/initializers/backtrace_silencers.rb
208
+ - spec/dummy/config/initializers/content_security_policy.rb
209
+ - spec/dummy/config/initializers/cookies_serializer.rb
210
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
211
+ - spec/dummy/config/initializers/inflections.rb
212
+ - spec/dummy/config/initializers/mime_types.rb
213
+ - spec/dummy/config/initializers/wrap_parameters.rb
214
+ - spec/dummy/config/locales/en.yml
215
+ - spec/dummy/config/puma.rb
216
+ - spec/dummy/config/routes.rb
217
+ - spec/dummy/config/spring.rb
218
+ - spec/dummy/config/storage.yml
219
+ - spec/dummy/db/schema.rb
220
+ - spec/dummy/lib/assets/.keep
221
+ - spec/dummy/log/.keep
222
+ - spec/dummy/public/404.html
223
+ - spec/dummy/public/422.html
224
+ - spec/dummy/public/500.html
225
+ - spec/dummy/public/apple-touch-icon-precomposed.png
226
+ - spec/dummy/public/apple-touch-icon.png
227
+ - spec/dummy/public/favicon.ico
228
+ - spec/dummy/tmp/development_secret.txt
229
+ - spec/fixtures/accounts.yml
230
+ - spec/fixtures/custom_primary_key_tasks.yml
231
+ - spec/fixtures/global_projects.yml
232
+ - spec/fixtures/projects.yml
233
+ - spec/helpers/tenant_helper_spec.rb
234
+ - spec/middlewares/test_tenant_middleware_spec.rb
235
+ - spec/models/model_extensions_spec.rb
161
236
  - spec/spec_helper.rb
162
- homepage: http://www.rollcallapp.com/blog
237
+ homepage: https://github.com/ErwinM/acts_as_tenant
163
238
  licenses: []
164
239
  metadata: {}
165
- post_install_message:
240
+ post_install_message:
166
241
  rdoc_options: []
167
242
  require_paths:
168
243
  - lib
@@ -177,22 +252,89 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
252
  - !ruby/object:Gem::Version
178
253
  version: '0'
179
254
  requirements: []
180
- rubyforge_project: acts_as_tenant
181
- rubygems_version: 2.4.5.1
182
- signing_key:
255
+ rubygems_version: 3.1.4
256
+ signing_key:
183
257
  specification_version: 4
184
258
  summary: Add multi-tenancy to Rails applications using a shared db strategy
185
259
  test_files:
186
- - spec/active_record_helper.rb
187
- - spec/active_record_models.rb
188
260
  - spec/acts_as_tenant/configuration_spec.rb
189
- - spec/acts_as_tenant/model_extensions_spec.rb
190
261
  - spec/acts_as_tenant/sidekiq_spec.rb
191
- - spec/acts_as_tenant/tenant_by_filter_spec.rb
192
- - spec/acts_as_tenant/tenant_by_subdomain_or_domain.rb
193
- - spec/acts_as_tenant/tenant_by_subdomain_spec.rb
194
- - spec/database.yml
195
- - spec/mongoid.yml
196
- - spec/mongoid_helper.rb
197
- - spec/mongoid_models.rb
262
+ - spec/controllers/filter_spec.rb
263
+ - spec/controllers/subdomain_or_domain_spec.rb
264
+ - spec/controllers/subdomain_spec.rb
265
+ - spec/dummy/.ruby-version
266
+ - spec/dummy/Rakefile
267
+ - spec/dummy/app/assets/config/manifest.js
268
+ - spec/dummy/app/assets/images/.keep
269
+ - spec/dummy/app/assets/stylesheets/application.css
270
+ - spec/dummy/app/channels/application_cable/channel.rb
271
+ - spec/dummy/app/channels/application_cable/connection.rb
272
+ - spec/dummy/app/controllers/application_controller.rb
273
+ - spec/dummy/app/controllers/concerns/.keep
274
+ - spec/dummy/app/helpers/application_helper.rb
275
+ - spec/dummy/app/javascript/packs/application.js
276
+ - spec/dummy/app/jobs/application_job.rb
277
+ - spec/dummy/app/mailers/application_mailer.rb
278
+ - spec/dummy/app/mailers/user_mailer.rb
279
+ - spec/dummy/app/models/account.rb
280
+ - spec/dummy/app/models/aliased_task.rb
281
+ - spec/dummy/app/models/article.rb
282
+ - spec/dummy/app/models/comment.rb
283
+ - spec/dummy/app/models/concerns/.keep
284
+ - spec/dummy/app/models/custom_counter_cache_task.rb
285
+ - spec/dummy/app/models/custom_foreign_key_task.rb
286
+ - spec/dummy/app/models/custom_primary_key_task.rb
287
+ - spec/dummy/app/models/global_project.rb
288
+ - spec/dummy/app/models/manager.rb
289
+ - spec/dummy/app/models/polymorphic_tenant_comment.rb
290
+ - spec/dummy/app/models/project.rb
291
+ - spec/dummy/app/models/task.rb
292
+ - spec/dummy/app/models/unique_task.rb
293
+ - spec/dummy/app/models/unscoped_model.rb
294
+ - spec/dummy/app/views/layouts/application.html.erb
295
+ - spec/dummy/app/views/layouts/mailer.html.erb
296
+ - spec/dummy/app/views/layouts/mailer.text.erb
297
+ - spec/dummy/bin/rails
298
+ - spec/dummy/bin/rake
299
+ - spec/dummy/bin/setup
300
+ - spec/dummy/config.ru
301
+ - spec/dummy/config/application.rb
302
+ - spec/dummy/config/boot.rb
303
+ - spec/dummy/config/cable.yml
304
+ - spec/dummy/config/database.yml
305
+ - spec/dummy/config/environment.rb
306
+ - spec/dummy/config/environments/development.rb
307
+ - spec/dummy/config/environments/production.rb
308
+ - spec/dummy/config/environments/test.rb
309
+ - spec/dummy/config/initializers/application_controller_renderer.rb
310
+ - spec/dummy/config/initializers/assets.rb
311
+ - spec/dummy/config/initializers/backtrace_silencers.rb
312
+ - spec/dummy/config/initializers/content_security_policy.rb
313
+ - spec/dummy/config/initializers/cookies_serializer.rb
314
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
315
+ - spec/dummy/config/initializers/inflections.rb
316
+ - spec/dummy/config/initializers/mime_types.rb
317
+ - spec/dummy/config/initializers/wrap_parameters.rb
318
+ - spec/dummy/config/locales/en.yml
319
+ - spec/dummy/config/puma.rb
320
+ - spec/dummy/config/routes.rb
321
+ - spec/dummy/config/spring.rb
322
+ - spec/dummy/config/storage.yml
323
+ - spec/dummy/db/schema.rb
324
+ - spec/dummy/lib/assets/.keep
325
+ - spec/dummy/log/.keep
326
+ - spec/dummy/public/404.html
327
+ - spec/dummy/public/422.html
328
+ - spec/dummy/public/500.html
329
+ - spec/dummy/public/apple-touch-icon-precomposed.png
330
+ - spec/dummy/public/apple-touch-icon.png
331
+ - spec/dummy/public/favicon.ico
332
+ - spec/dummy/tmp/development_secret.txt
333
+ - spec/fixtures/accounts.yml
334
+ - spec/fixtures/custom_primary_key_tasks.yml
335
+ - spec/fixtures/global_projects.yml
336
+ - spec/fixtures/projects.yml
337
+ - spec/helpers/tenant_helper_spec.rb
338
+ - spec/middlewares/test_tenant_middleware_spec.rb
339
+ - spec/models/model_extensions_spec.rb
198
340
  - spec/spec_helper.rb