acts_as_tenant 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +86 -25
- data/Rakefile +5 -3
- data/lib/acts_as_tenant.rb +112 -14
- data/lib/acts_as_tenant/configuration.rb +6 -19
- data/lib/acts_as_tenant/controller_extensions.rb +10 -59
- data/lib/acts_as_tenant/controller_extensions/filter.rb +13 -0
- data/lib/acts_as_tenant/controller_extensions/subdomain.rb +20 -0
- data/lib/acts_as_tenant/controller_extensions/subdomain_or_domain.rb +20 -0
- data/lib/acts_as_tenant/errors.rb +3 -4
- data/lib/acts_as_tenant/model_extensions.rb +33 -136
- data/lib/acts_as_tenant/sidekiq.rb +11 -7
- data/lib/acts_as_tenant/tenant_helper.rb +7 -0
- data/lib/acts_as_tenant/test_tenant_middleware.rb +15 -0
- data/lib/acts_as_tenant/version.rb +1 -1
- data/spec/acts_as_tenant/configuration_spec.rb +8 -19
- data/spec/acts_as_tenant/sidekiq_spec.rb +14 -19
- data/spec/{acts_as_tenant/tenant_by_filter_spec.rb → controllers/filter_spec.rb} +7 -12
- data/spec/controllers/subdomain_or_domain_spec.rb +55 -0
- data/spec/controllers/subdomain_spec.rb +49 -0
- data/spec/dummy/.ruby-version +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/packs/application.js +15 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/mailers/user_mailer.rb +5 -0
- data/spec/dummy/app/models/account.rb +4 -0
- data/spec/dummy/app/models/aliased_task.rb +4 -0
- data/spec/dummy/app/models/article.rb +3 -0
- data/spec/dummy/app/models/comment.rb +5 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/custom_counter_cache_task.rb +4 -0
- data/spec/dummy/app/models/custom_foreign_key_task.rb +4 -0
- data/spec/dummy/app/models/custom_primary_key_task.rb +4 -0
- data/spec/dummy/app/models/global_project.rb +6 -0
- data/spec/dummy/app/models/manager.rb +4 -0
- data/spec/dummy/app/models/polymorphic_tenant_comment.rb +5 -0
- data/spec/dummy/app/models/project.rb +8 -0
- data/spec/dummy/app/models/task.rb +7 -0
- data/spec/dummy/app/models/unique_task.rb +5 -0
- data/spec/dummy/app/models/unscoped_model.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +19 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +19 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +62 -0
- data/spec/dummy/config/environments/production.rb +112 -0
- data/spec/dummy/config/environments/test.rb +49 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +40 -0
- data/spec/dummy/config/puma.rb +38 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/db/schema.rb +84 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/development_secret.txt +1 -0
- data/spec/fixtures/accounts.yml +10 -0
- data/spec/fixtures/custom_primary_key_tasks.yml +2 -0
- data/spec/fixtures/global_projects.yml +13 -0
- data/spec/fixtures/projects.yml +10 -0
- data/spec/helpers/tenant_helper_spec.rb +16 -0
- data/spec/middlewares/test_tenant_middleware_spec.rb +86 -0
- data/spec/models/model_extensions_spec.rb +383 -0
- data/spec/spec_helper.rb +9 -13
- metadata +201 -41
- data/.gitignore +0 -7
- data/.travis.yml +0 -4
- data/CHANGELOG.md +0 -119
- data/Gemfile +0 -4
- data/_config.yml +0 -1
- data/acts_as_tenant.gemspec +0 -32
- data/docs/blog_post.md +0 -67
- data/rails/init.rb +0 -2
- data/spec/active_record_helper.rb +0 -22
- data/spec/active_record_models.rb +0 -143
- data/spec/acts_as_tenant/model_extensions_spec.rb +0 -476
- data/spec/acts_as_tenant/tenant_by_subdomain_or_domain.rb +0 -46
- data/spec/acts_as_tenant/tenant_by_subdomain_spec.rb +0 -32
- data/spec/database.yml +0 -3
@@ -1,46 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
#Setup test specific ApplicationController
|
4
|
-
class Account; end # this is so the spec will work in isolation
|
5
|
-
|
6
|
-
class ApplicationController < ActionController::Base
|
7
|
-
include Rails.application.routes.url_helpers
|
8
|
-
set_current_tenant_by_subdomain_or_domain
|
9
|
-
end
|
10
|
-
|
11
|
-
# Start testing
|
12
|
-
describe ApplicationController, :type => :controller do
|
13
|
-
controller do
|
14
|
-
def index
|
15
|
-
render :text => "custom called"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'Finds the correct tenant with a example1.com' do
|
20
|
-
@request.host = "example1.com"
|
21
|
-
expect(Account).to receive(:where).with({domain: 'example1.com'}) {['account1']}
|
22
|
-
get :index
|
23
|
-
expect(ActsAsTenant.current_tenant).to eq 'account1'
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'Finds the correct tenant with a subdomain.example.com' do
|
27
|
-
@request.host = "subdomain.example.com"
|
28
|
-
expect(Account).to receive(:where).with({subdomain: 'subdomain'}) {['account1']}
|
29
|
-
get :index
|
30
|
-
expect(ActsAsTenant.current_tenant).to eq "account1"
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'Finds the correct tenant with a www.subdomain.example.com' do
|
34
|
-
@request.host = "subdomain.example.com"
|
35
|
-
expect(Account).to receive(:where).with({subdomain: 'subdomain'}) {['account1']}
|
36
|
-
get :index
|
37
|
-
expect(ActsAsTenant.current_tenant).to eq "account1"
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'Ignores case when finding tenant by subdomain' do
|
41
|
-
@request.host = "SubDomain.example.com"
|
42
|
-
expect(Account).to receive(:where).with({subdomain: 'subdomain'}) {['account1']}
|
43
|
-
get :index
|
44
|
-
expect(ActsAsTenant.current_tenant).to eq "account1"
|
45
|
-
end
|
46
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
#Setup test specific ApplicationController
|
4
|
-
class Account; end # this is so the spec will work in isolation
|
5
|
-
|
6
|
-
class ApplicationController < ActionController::Base
|
7
|
-
include Rails.application.routes.url_helpers
|
8
|
-
set_current_tenant_by_subdomain
|
9
|
-
end
|
10
|
-
|
11
|
-
# Start testing
|
12
|
-
describe ApplicationController, :type => :controller do
|
13
|
-
controller do
|
14
|
-
def index
|
15
|
-
render :plain => "custom called"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'Finds the correct tenant with a subdomain.example.com' do
|
20
|
-
@request.host = "account1.example.com"
|
21
|
-
expect(Account).to receive(:where).with({subdomain: 'account1'}) {['account1']}
|
22
|
-
get :index
|
23
|
-
expect(ActsAsTenant.current_tenant).to eq 'account1'
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'Finds the correct tenant with a www.subdomain.example.com' do
|
27
|
-
@request.host = "www.account1.example.com"
|
28
|
-
expect(Account).to receive(:where).with({subdomain: 'account1'}) {['account1']}
|
29
|
-
get :index
|
30
|
-
expect(ActsAsTenant.current_tenant).to eq 'account1'
|
31
|
-
end
|
32
|
-
end
|
data/spec/database.yml
DELETED