acts_as_tenant 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -4
- data/lib/acts_as_tenant/errors.rb +0 -3
- data/lib/acts_as_tenant/model_extensions.rb +16 -6
- data/lib/acts_as_tenant/version.rb +1 -1
- data/lib/acts_as_tenant.rb +19 -1
- metadata +4 -170
- data/spec/acts_as_tenant/configuration_spec.rb +0 -17
- data/spec/acts_as_tenant/sidekiq_spec.rb +0 -58
- data/spec/controllers/filter_spec.rb +0 -28
- data/spec/controllers/subdomain_or_domain_spec.rb +0 -55
- data/spec/controllers/subdomain_spec.rb +0 -49
- data/spec/dummy/.ruby-version +0 -1
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/config/manifest.js +0 -2
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/channels/application_cable/channel.rb +0 -4
- data/spec/dummy/app/channels/application_cable/connection.rb +0 -4
- data/spec/dummy/app/controllers/application_controller.rb +0 -2
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/javascript/packs/application.js +0 -15
- data/spec/dummy/app/jobs/application_job.rb +0 -7
- data/spec/dummy/app/mailers/application_mailer.rb +0 -4
- data/spec/dummy/app/mailers/user_mailer.rb +0 -5
- data/spec/dummy/app/models/account.rb +0 -4
- data/spec/dummy/app/models/aliased_task.rb +0 -4
- data/spec/dummy/app/models/article.rb +0 -3
- data/spec/dummy/app/models/comment.rb +0 -5
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/custom_counter_cache_task.rb +0 -4
- data/spec/dummy/app/models/custom_foreign_key_task.rb +0 -4
- data/spec/dummy/app/models/custom_primary_key_task.rb +0 -4
- data/spec/dummy/app/models/global_project.rb +0 -6
- data/spec/dummy/app/models/global_project_with_conditions.rb +0 -6
- data/spec/dummy/app/models/global_project_with_if.rb +0 -6
- data/spec/dummy/app/models/manager.rb +0 -4
- data/spec/dummy/app/models/polymorphic_tenant_comment.rb +0 -5
- data/spec/dummy/app/models/project.rb +0 -8
- data/spec/dummy/app/models/task.rb +0 -7
- data/spec/dummy/app/models/unique_task.rb +0 -5
- data/spec/dummy/app/models/unscoped_model.rb +0 -3
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -33
- data/spec/dummy/config/application.rb +0 -19
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/database.yml +0 -19
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -62
- data/spec/dummy/config/environments/production.rb +0 -112
- data/spec/dummy/config/environments/test.rb +0 -49
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/spec/dummy/config/initializers/assets.rb +0 -12
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/content_security_policy.rb +0 -28
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -40
- data/spec/dummy/config/puma.rb +0 -38
- data/spec/dummy/config/routes.rb +0 -4
- data/spec/dummy/config/spring.rb +0 -6
- data/spec/dummy/config/storage.yml +0 -34
- data/spec/dummy/config.ru +0 -5
- data/spec/dummy/db/schema.rb +0 -84
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- 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 +0 -1
- data/spec/fixtures/accounts.yml +0 -10
- data/spec/fixtures/custom_primary_key_tasks.yml +0 -2
- data/spec/fixtures/global_projects.yml +0 -13
- data/spec/fixtures/projects.yml +0 -10
- data/spec/helpers/tenant_helper_spec.rb +0 -16
- data/spec/middlewares/test_tenant_middleware_spec.rb +0 -86
- data/spec/models/model_extensions_spec.rb +0 -413
- data/spec/spec_helper.rb +0 -19
@@ -1,40 +0,0 @@
|
|
1
|
-
# Files in the config/locales directory are used for internationalization
|
2
|
-
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
-
# than English, add the necessary files in this directory.
|
4
|
-
#
|
5
|
-
# To use the locales, use `I18n.t`:
|
6
|
-
#
|
7
|
-
# I18n.t 'hello'
|
8
|
-
#
|
9
|
-
# In views, this is aliased to just `t`:
|
10
|
-
#
|
11
|
-
# <%= t('hello') %>
|
12
|
-
#
|
13
|
-
# To use a different locale, set it with `I18n.locale`:
|
14
|
-
#
|
15
|
-
# I18n.locale = :es
|
16
|
-
#
|
17
|
-
# This would use the information in config/locales/es.yml.
|
18
|
-
#
|
19
|
-
# The following keys must be escaped otherwise they will not be retrieved by
|
20
|
-
# the default I18n backend:
|
21
|
-
#
|
22
|
-
# true, false, on, off, yes, no
|
23
|
-
#
|
24
|
-
# Instead, surround them with single quotes.
|
25
|
-
#
|
26
|
-
# en:
|
27
|
-
# 'true': 'foo'
|
28
|
-
#
|
29
|
-
# To learn more, please read the Rails Internationalization guide
|
30
|
-
# available at https://guides.rubyonrails.org/i18n.html.
|
31
|
-
|
32
|
-
en:
|
33
|
-
hello: "Hello world"
|
34
|
-
notifications:
|
35
|
-
noticed/i18n_example:
|
36
|
-
message: "This is a notification"
|
37
|
-
noticed:
|
38
|
-
scoped_i18n_example:
|
39
|
-
message: "This is a custom scoped trnaslation"
|
40
|
-
|
data/spec/dummy/config/puma.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Puma can serve each request in a thread from an internal thread pool.
|
2
|
-
# The `threads` method setting takes two numbers: a minimum and maximum.
|
3
|
-
# Any libraries that use thread pools should be configured to match
|
4
|
-
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
5
|
-
# and maximum; this matches the default thread size of Active Record.
|
6
|
-
#
|
7
|
-
max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
|
8
|
-
min_threads_count = ENV.fetch("RAILS_MIN_THREADS", max_threads_count)
|
9
|
-
threads min_threads_count, max_threads_count
|
10
|
-
|
11
|
-
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
12
|
-
#
|
13
|
-
port ENV.fetch("PORT", 3000)
|
14
|
-
|
15
|
-
# Specifies the `environment` that Puma will run in.
|
16
|
-
#
|
17
|
-
environment ENV.fetch("RAILS_ENV", "development")
|
18
|
-
|
19
|
-
# Specifies the `pidfile` that Puma will use.
|
20
|
-
pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid")
|
21
|
-
|
22
|
-
# Specifies the number of `workers` to boot in clustered mode.
|
23
|
-
# Workers are forked web server processes. If using threads and workers together
|
24
|
-
# the concurrency of the application would be max `threads` * `workers`.
|
25
|
-
# Workers do not work on JRuby or Windows (both of which do not support
|
26
|
-
# processes).
|
27
|
-
#
|
28
|
-
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
29
|
-
|
30
|
-
# Use the `preload_app!` method when specifying a `workers` number.
|
31
|
-
# This directive tells Puma to first boot the application and load code
|
32
|
-
# before forking the application. This takes advantage of Copy On Write
|
33
|
-
# process behavior so workers use less memory.
|
34
|
-
#
|
35
|
-
# preload_app!
|
36
|
-
|
37
|
-
# Allow puma to be restarted by `rails restart` command.
|
38
|
-
plugin :tmp_restart
|
data/spec/dummy/config/routes.rb
DELETED
data/spec/dummy/config/spring.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
test:
|
2
|
-
service: Disk
|
3
|
-
root: <%= Rails.root.join("tmp/storage") %>
|
4
|
-
|
5
|
-
local:
|
6
|
-
service: Disk
|
7
|
-
root: <%= Rails.root.join("storage") %>
|
8
|
-
|
9
|
-
# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
|
10
|
-
# amazon:
|
11
|
-
# service: S3
|
12
|
-
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
13
|
-
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
14
|
-
# region: us-east-1
|
15
|
-
# bucket: your_own_bucket
|
16
|
-
|
17
|
-
# Remember not to checkin your GCS keyfile to a repository
|
18
|
-
# google:
|
19
|
-
# service: GCS
|
20
|
-
# project: your_project
|
21
|
-
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
|
22
|
-
# bucket: your_own_bucket
|
23
|
-
|
24
|
-
# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
|
25
|
-
# microsoft:
|
26
|
-
# service: AzureStorage
|
27
|
-
# storage_account_name: your_account_name
|
28
|
-
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
|
29
|
-
# container: your_container_name
|
30
|
-
|
31
|
-
# mirror:
|
32
|
-
# service: Mirror
|
33
|
-
# primary: local
|
34
|
-
# mirrors: [ amazon, google, microsoft ]
|
data/spec/dummy/config.ru
DELETED
data/spec/dummy/db/schema.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# This file is auto-generated from the current state of the database. Instead
|
2
|
-
# of editing this file, please use the migrations feature of Active Record to
|
3
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
-
#
|
5
|
-
# This file is the source Rails uses to define your schema when running `rails
|
6
|
-
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
|
7
|
-
# be faster and is potentially less error prone than running all of your
|
8
|
-
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
-
# migrations use external dependencies or application code.
|
10
|
-
#
|
11
|
-
# It's strongly recommended that you check this file into your version control system.
|
12
|
-
|
13
|
-
ActiveRecord::Schema.define(version: 1) do
|
14
|
-
create_table :accounts, force: true do |t|
|
15
|
-
t.column :name, :string
|
16
|
-
t.column :subdomain, :string
|
17
|
-
t.column :domain, :string
|
18
|
-
t.column :projects_count, :integer, default: 0
|
19
|
-
end
|
20
|
-
|
21
|
-
create_table :projects, force: true do |t|
|
22
|
-
t.column :name, :string
|
23
|
-
t.column :account_id, :integer
|
24
|
-
end
|
25
|
-
|
26
|
-
create_table :managers, force: true do |t|
|
27
|
-
t.column :name, :string
|
28
|
-
t.column :project_id, :integer
|
29
|
-
t.column :account_id, :integer
|
30
|
-
end
|
31
|
-
|
32
|
-
create_table :tasks, force: true do |t|
|
33
|
-
t.column :name, :string
|
34
|
-
t.column :account_id, :integer
|
35
|
-
t.column :project_id, :integer
|
36
|
-
t.column :completed, :boolean
|
37
|
-
end
|
38
|
-
|
39
|
-
create_table :countries, force: true do |t|
|
40
|
-
t.column :name, :string
|
41
|
-
end
|
42
|
-
|
43
|
-
create_table :unscoped_models, force: true do |t|
|
44
|
-
t.column :name, :string
|
45
|
-
end
|
46
|
-
|
47
|
-
create_table :aliased_tasks, force: true do |t|
|
48
|
-
t.column :name, :string
|
49
|
-
t.column :project_alias_id, :integer
|
50
|
-
t.column :account_id, :integer
|
51
|
-
end
|
52
|
-
|
53
|
-
create_table :unique_tasks, force: true do |t|
|
54
|
-
t.column :name, :string
|
55
|
-
t.column :user_defined_scope, :string
|
56
|
-
t.column :project_id, :integer
|
57
|
-
t.column :account_id, :integer
|
58
|
-
end
|
59
|
-
|
60
|
-
create_table :custom_foreign_key_tasks, force: true do |t|
|
61
|
-
t.column :name, :string
|
62
|
-
t.column :accountID, :integer
|
63
|
-
end
|
64
|
-
|
65
|
-
create_table :custom_primary_key_tasks, force: true do |t|
|
66
|
-
t.column :name, :string
|
67
|
-
end
|
68
|
-
|
69
|
-
create_table :articles, force: true do |t|
|
70
|
-
t.column :title, :string
|
71
|
-
end
|
72
|
-
|
73
|
-
create_table :comments, force: true do |t|
|
74
|
-
t.column :commentable_id, :integer
|
75
|
-
t.column :commentable_type, :string
|
76
|
-
t.column :account_id, :integer
|
77
|
-
end
|
78
|
-
|
79
|
-
create_table :polymorphic_tenant_comments, force: true do |t|
|
80
|
-
t.column :polymorphic_tenant_commentable_id, :integer
|
81
|
-
t.column :polymorphic_tenant_commentable_type, :string
|
82
|
-
t.column :account_id, :integer
|
83
|
-
end
|
84
|
-
end
|
data/spec/dummy/lib/assets/.keep
DELETED
File without changes
|
data/spec/dummy/log/.keep
DELETED
File without changes
|
data/spec/dummy/public/404.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
.rails-default-error-page {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
.rails-default-error-page div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
.rails-default-error-page div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
.rails-default-error-page h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
.rails-default-error-page div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body class="rails-default-error-page">
|
58
|
-
<!-- This file lives in public/404.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/spec/dummy/public/422.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
.rails-default-error-page {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
.rails-default-error-page div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
.rails-default-error-page div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
.rails-default-error-page h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
.rails-default-error-page div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body class="rails-default-error-page">
|
58
|
-
<!-- This file lives in public/422.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The change you wanted was rejected.</h1>
|
62
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/spec/dummy/public/500.html
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
.rails-default-error-page {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
.rails-default-error-page div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
.rails-default-error-page div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
.rails-default-error-page h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
.rails-default-error-page div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body class="rails-default-error-page">
|
58
|
-
<!-- This file lives in public/500.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>We're sorry, but something went wrong.</h1>
|
62
|
-
</div>
|
63
|
-
<p>If you are the application owner check the logs for more information.</p>
|
64
|
-
</div>
|
65
|
-
</body>
|
66
|
-
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
f1e8981c98a3cd825ba410f2080160547945e8c380645e0dfaeba509fa55291dcd4e317d6c2ba08bc94a4110b6c567987a66f616f67e3b5f62e11a4b216820e6
|
data/spec/fixtures/accounts.yml
DELETED
data/spec/fixtures/projects.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe ActionView::Base, type: :helper do
|
4
|
-
it "responds ot current_tenant" do
|
5
|
-
expect(helper).to respond_to(:current_tenant)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "returns nil if no tenant set" do
|
9
|
-
expect(helper.current_tenant).to be_nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it "returns the current tenant" do
|
13
|
-
ActsAsTenant.current_tenant = accounts(:foo)
|
14
|
-
expect(helper.current_tenant).to eq(accounts(:foo))
|
15
|
-
end
|
16
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "acts_as_tenant/test_tenant_middleware"
|
3
|
-
|
4
|
-
class TestRackApp1
|
5
|
-
def call(_env)
|
6
|
-
ActsAsTenant.current_tenant = Account.first
|
7
|
-
TestReceiver.assert_current_id(ActsAsTenant.current_tenant.id)
|
8
|
-
ActsAsTenant.current_tenant = nil
|
9
|
-
[200, {}, ["OK"]]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class TestRackApp2
|
14
|
-
def call(_env)
|
15
|
-
TestReceiver.assert_current_id(ActsAsTenant.current_tenant.try(:id))
|
16
|
-
[200, {}, ["OK"]]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class TestReceiver
|
21
|
-
def self.assert_current_id(id)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe ActsAsTenant::TestTenantMiddleware do
|
26
|
-
fixtures :accounts
|
27
|
-
after { ActsAsTenant.test_tenant = nil }
|
28
|
-
|
29
|
-
subject { request.get("/some/path") }
|
30
|
-
|
31
|
-
let(:middleware) { described_class.new(app) }
|
32
|
-
let(:request) { Rack::MockRequest.new(middleware) }
|
33
|
-
|
34
|
-
let!(:account1) { accounts(:foo) }
|
35
|
-
let!(:account2) { accounts(:bar) }
|
36
|
-
|
37
|
-
context "when test_tenant is nil before processing" do
|
38
|
-
context "that switches tenancies" do
|
39
|
-
let(:app) { TestRackApp1.new }
|
40
|
-
|
41
|
-
it "should remain nil after processing" do
|
42
|
-
expect(ActsAsTenant.current_tenant).to be_nil
|
43
|
-
expect(TestReceiver).to receive(:assert_current_id).with(account1.id)
|
44
|
-
expect(subject.status).to eq 200
|
45
|
-
expect(ActsAsTenant.current_tenant).to be_nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context "that does not switch tenancies" do
|
50
|
-
let(:app) { TestRackApp2.new }
|
51
|
-
|
52
|
-
it "should remain nil after processing" do
|
53
|
-
expect(ActsAsTenant.current_tenant).to be_nil
|
54
|
-
expect(TestReceiver).to receive(:assert_current_id).with(nil)
|
55
|
-
expect(subject.status).to eq 200
|
56
|
-
expect(ActsAsTenant.current_tenant).to be_nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "when test_tenant is assigned before processing" do
|
62
|
-
before { ActsAsTenant.test_tenant = account2 }
|
63
|
-
|
64
|
-
context "that switches tenancies" do
|
65
|
-
let(:app) { TestRackApp1.new }
|
66
|
-
|
67
|
-
it "should remain assigned after processing" do
|
68
|
-
expect(ActsAsTenant.current_tenant).to eq account2
|
69
|
-
expect(TestReceiver).to receive(:assert_current_id).with(account1.id)
|
70
|
-
expect(subject.status).to eq 200
|
71
|
-
expect(ActsAsTenant.current_tenant).to eq account2
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "that does not switch tenancies" do
|
76
|
-
let(:app) { TestRackApp2.new }
|
77
|
-
|
78
|
-
it "should remain assigned after processing" do
|
79
|
-
expect(ActsAsTenant.current_tenant).to eq account2
|
80
|
-
expect(TestReceiver).to receive(:assert_current_id).with(nil)
|
81
|
-
expect(subject.status).to eq 200
|
82
|
-
expect(ActsAsTenant.current_tenant).to eq account2
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|