ros-apartment 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/.rubocop-linter.yml +22 -0
- data/.pryrc +5 -3
- data/.rubocop.yml +17 -0
- data/.rubocop_todo.yml +29 -0
- data/.story_branch.yml +4 -0
- data/.travis.yml +12 -11
- data/Appraisals +18 -18
- data/Gemfile +4 -1
- data/README.md +33 -5
- data/Rakefile +2 -0
- data/apartment.gemspec +6 -6
- data/gemfiles/rails_4_2.gemfile +12 -10
- data/gemfiles/rails_5_0.gemfile +11 -9
- data/gemfiles/rails_5_1.gemfile +11 -9
- data/gemfiles/rails_5_2.gemfile +10 -8
- data/gemfiles/rails_6_0.gemfile +11 -9
- data/gemfiles/rails_master.gemfile +11 -9
- data/lib/apartment/adapters/abstract_adapter.rb +34 -34
- data/lib/apartment/adapters/abstract_jdbc_adapter.rb +4 -3
- data/lib/apartment/adapters/jdbc_mysql_adapter.rb +3 -3
- data/lib/apartment/adapters/jdbc_postgresql_adapter.rb +13 -11
- data/lib/apartment/adapters/mysql2_adapter.rb +10 -9
- data/lib/apartment/adapters/postgis_adapter.rb +3 -2
- data/lib/apartment/adapters/postgresql_adapter.rb +28 -25
- data/lib/apartment/adapters/sqlite3_adapter.rb +16 -8
- data/lib/apartment/console.rb +28 -3
- data/lib/apartment/custom_console.rb +26 -0
- data/lib/apartment/deprecation.rb +2 -1
- data/lib/apartment/elevators/domain.rb +4 -3
- data/lib/apartment/elevators/first_subdomain.rb +3 -2
- data/lib/apartment/elevators/generic.rb +4 -3
- data/lib/apartment/elevators/host.rb +6 -1
- data/lib/apartment/elevators/host_hash.rb +6 -2
- data/lib/apartment/elevators/subdomain.rb +9 -5
- data/lib/apartment/migrator.rb +4 -3
- data/lib/apartment/railtie.rb +13 -5
- data/lib/apartment/reloader.rb +2 -1
- data/lib/apartment/tasks/enhancements.rb +4 -6
- data/lib/apartment/tenant.rb +3 -4
- data/lib/apartment/version.rb +3 -1
- data/lib/apartment.rb +15 -9
- data/lib/generators/apartment/install/install_generator.rb +4 -3
- data/lib/generators/apartment/install/templates/apartment.rb +3 -2
- data/lib/tasks/apartment.rake +19 -18
- data/spec/adapters/jdbc_mysql_adapter_spec.rb +5 -4
- data/spec/adapters/jdbc_postgresql_adapter_spec.rb +10 -12
- data/spec/adapters/mysql2_adapter_spec.rb +15 -13
- data/spec/adapters/postgresql_adapter_spec.rb +22 -20
- data/spec/adapters/sqlite3_adapter_spec.rb +41 -23
- data/spec/apartment_spec.rb +4 -2
- data/spec/dummy/app/controllers/application_controller.rb +4 -3
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/application_record.rb +6 -0
- data/spec/dummy/app/models/company.rb +4 -2
- data/spec/dummy/app/models/user.rb +4 -2
- data/spec/dummy/config/application.rb +11 -9
- data/spec/dummy/config/boot.rb +4 -2
- data/spec/dummy/config/environment.rb +3 -1
- data/spec/dummy/config/environments/development.rb +2 -1
- data/spec/dummy/config/environments/production.rb +3 -1
- data/spec/dummy/config/environments/test.rb +3 -1
- data/spec/dummy/config/initializers/apartment.rb +4 -2
- data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb +1 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/config/initializers/secret_token.rb +2 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -1
- data/spec/dummy/config/routes.rb +3 -1
- data/spec/dummy/config.ru +3 -1
- data/spec/dummy/db/seeds/import.rb +3 -1
- data/spec/dummy/script/rails +4 -2
- data/spec/dummy_engine/config/initializers/apartment.rb +4 -3
- data/spec/dummy_engine/lib/dummy_engine/engine.rb +2 -0
- data/spec/dummy_engine/lib/dummy_engine/version.rb +3 -1
- data/spec/dummy_engine/lib/dummy_engine.rb +3 -1
- data/spec/dummy_engine/test/dummy/config/application.rb +4 -2
- data/spec/dummy_engine/test/dummy/config/boot.rb +4 -2
- data/spec/dummy_engine/test/dummy/config/environment.rb +3 -1
- data/spec/dummy_engine/test/dummy/config/environments/development.rb +2 -0
- data/spec/dummy_engine/test/dummy/config/environments/production.rb +2 -0
- data/spec/dummy_engine/test/dummy/config/environments/test.rb +2 -0
- data/spec/dummy_engine/test/dummy/config/initializers/assets.rb +2 -0
- data/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb +3 -1
- data/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/spec/dummy_engine/test/dummy/config/initializers/inflections.rb +1 -0
- data/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy_engine/test/dummy/config/initializers/session_store.rb +2 -0
- data/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/spec/dummy_engine/test/dummy/config/routes.rb +2 -0
- data/spec/dummy_engine/test/dummy/config.ru +3 -1
- data/spec/examples/connection_adapter_examples.rb +15 -13
- data/spec/examples/generic_adapter_custom_configuration_example.rb +21 -23
- data/spec/examples/generic_adapter_examples.rb +40 -39
- data/spec/examples/schema_adapter_examples.rb +93 -88
- data/spec/integration/apartment_rake_integration_spec.rb +24 -24
- data/spec/integration/query_caching_spec.rb +10 -8
- data/spec/integration/use_within_an_engine_spec.rb +5 -5
- data/spec/schemas/v1.rb +2 -3
- data/spec/schemas/v2.rb +22 -24
- data/spec/schemas/v3.rb +26 -28
- data/spec/spec_helper.rb +8 -6
- data/spec/support/apartment_helpers.rb +9 -5
- data/spec/support/capybara_sessions.rb +5 -5
- data/spec/support/config.rb +5 -2
- data/spec/support/contexts.rb +10 -8
- data/spec/support/requirements.rb +19 -6
- data/spec/support/setup.rb +5 -5
- data/spec/tasks/apartment_rake_spec.rb +30 -35
- data/spec/tenant_spec.rb +48 -44
- data/spec/unit/config_spec.rb +26 -27
- data/spec/unit/elevators/domain_spec.rb +9 -8
- data/spec/unit/elevators/first_subdomain_spec.rb +14 -12
- data/spec/unit/elevators/generic_spec.rb +16 -15
- data/spec/unit/elevators/host_hash_spec.rb +9 -8
- data/spec/unit/elevators/host_spec.rb +26 -26
- data/spec/unit/elevators/subdomain_spec.rb +24 -23
- data/spec/unit/migrator_spec.rb +18 -17
- data/spec/unit/reloader_spec.rb +8 -8
- metadata +40 -22
@@ -1,29 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'apartment/elevators/host_hash'
|
3
5
|
|
4
6
|
describe Apartment::Elevators::HostHash do
|
7
|
+
subject(:elevator) { Apartment::Elevators::HostHash.new(proc {}, 'example.com' => 'example_tenant') }
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
describe "#parse_tenant_name" do
|
9
|
-
it "parses the host for a domain name" do
|
9
|
+
describe '#parse_tenant_name' do
|
10
|
+
it 'parses the host for a domain name' do
|
10
11
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'example.com')
|
11
12
|
expect(elevator.parse_tenant_name(request)).to eq('example_tenant')
|
12
13
|
end
|
13
14
|
|
14
|
-
it
|
15
|
+
it 'raises TenantNotFound exception if there is no host' do
|
15
16
|
request = ActionDispatch::Request.new('HTTP_HOST' => '')
|
16
17
|
expect { elevator.parse_tenant_name(request) }.to raise_error(Apartment::TenantNotFound)
|
17
18
|
end
|
18
19
|
|
19
|
-
it
|
20
|
+
it 'raises TenantNotFound exception if there is no database associated to current host' do
|
20
21
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'example2.com')
|
21
22
|
expect { elevator.parse_tenant_name(request) }.to raise_error(Apartment::TenantNotFound)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
describe
|
26
|
-
it
|
26
|
+
describe '#call' do
|
27
|
+
it 'switches to the proper tenant' do
|
27
28
|
expect(Apartment::Tenant).to receive(:switch).with('example_tenant')
|
28
29
|
|
29
30
|
elevator.call('HTTP_HOST' => 'example.com')
|
@@ -1,87 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'apartment/elevators/host'
|
3
5
|
|
4
6
|
describe Apartment::Elevators::Host do
|
7
|
+
subject(:elevator) { described_class.new(proc {}) }
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
describe "#parse_tenant_name" do
|
9
|
-
|
10
|
-
it "should return nil when no host" do
|
9
|
+
describe '#parse_tenant_name' do
|
10
|
+
it 'should return nil when no host' do
|
11
11
|
request = ActionDispatch::Request.new('HTTP_HOST' => '')
|
12
12
|
expect(elevator.parse_tenant_name(request)).to be_nil
|
13
13
|
end
|
14
14
|
|
15
|
-
context
|
15
|
+
context 'assuming no ignored_first_subdomains' do
|
16
16
|
before { allow(described_class).to receive(:ignored_first_subdomains).and_return([]) }
|
17
17
|
|
18
|
-
context
|
19
|
-
it
|
18
|
+
context 'with 3 parts' do
|
19
|
+
it 'should return the whole host' do
|
20
20
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.bar.com')
|
21
21
|
expect(elevator.parse_tenant_name(request)).to eq('foo.bar.com')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
context
|
26
|
-
it
|
25
|
+
context 'with 6 parts' do
|
26
|
+
it 'should return the whole host' do
|
27
27
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'one.two.three.foo.bar.com')
|
28
28
|
expect(elevator.parse_tenant_name(request)).to eq('one.two.three.foo.bar.com')
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
context
|
34
|
-
before { allow(described_class).to receive(:ignored_first_subdomains).and_return(%w
|
33
|
+
context 'assuming ignored_first_subdomains is set' do
|
34
|
+
before { allow(described_class).to receive(:ignored_first_subdomains).and_return(%w[www foo]) }
|
35
35
|
|
36
|
-
context
|
37
|
-
it
|
36
|
+
context 'with 3 parts' do
|
37
|
+
it 'should return host without www' do
|
38
38
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'www.bar.com')
|
39
39
|
expect(elevator.parse_tenant_name(request)).to eq('bar.com')
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
42
|
+
it 'should return host without foo' do
|
43
43
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.bar.com')
|
44
44
|
expect(elevator.parse_tenant_name(request)).to eq('bar.com')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
context
|
49
|
-
it
|
48
|
+
context 'with 6 parts' do
|
49
|
+
it 'should return host without www' do
|
50
50
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'www.one.two.three.foo.bar.com')
|
51
51
|
expect(elevator.parse_tenant_name(request)).to eq('one.two.three.foo.bar.com')
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
54
|
+
it 'should return host without www' do
|
55
55
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.one.two.three.bar.com')
|
56
56
|
expect(elevator.parse_tenant_name(request)).to eq('one.two.three.bar.com')
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context
|
62
|
-
it
|
61
|
+
context 'assuming localhost' do
|
62
|
+
it 'should return localhost' do
|
63
63
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'localhost')
|
64
64
|
expect(elevator.parse_tenant_name(request)).to eq('localhost')
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
context
|
69
|
-
it
|
68
|
+
context 'assuming ip address' do
|
69
|
+
it 'should return the ip address' do
|
70
70
|
request = ActionDispatch::Request.new('HTTP_HOST' => '127.0.0.1')
|
71
71
|
expect(elevator.parse_tenant_name(request)).to eq('127.0.0.1')
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
describe
|
77
|
-
it
|
76
|
+
describe '#call' do
|
77
|
+
it 'switches to the proper tenant' do
|
78
78
|
allow(described_class).to receive(:ignored_first_subdomains).and_return([])
|
79
79
|
expect(Apartment::Tenant).to receive(:switch).with('foo.bar.com')
|
80
80
|
elevator.call('HTTP_HOST' => 'foo.bar.com')
|
81
81
|
end
|
82
82
|
|
83
|
-
it
|
84
|
-
allow(described_class).to receive(:ignored_first_subdomains).and_return(%w
|
83
|
+
it 'ignores ignored_first_subdomains' do
|
84
|
+
allow(described_class).to receive(:ignored_first_subdomains).and_return(%w[foo])
|
85
85
|
expect(Apartment::Tenant).to receive(:switch).with('bar.com')
|
86
86
|
elevator.call('HTTP_HOST' => 'foo.bar.com')
|
87
87
|
end
|
@@ -1,70 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'apartment/elevators/subdomain'
|
3
5
|
|
4
6
|
describe Apartment::Elevators::Subdomain do
|
7
|
+
subject(:elevator) { described_class.new(proc {}) }
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
context "assuming one tld" do
|
10
|
-
it "should parse subdomain" do
|
9
|
+
describe '#parse_tenant_name' do
|
10
|
+
context 'assuming one tld' do
|
11
|
+
it 'should parse subdomain' do
|
11
12
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.bar.com')
|
12
13
|
expect(elevator.parse_tenant_name(request)).to eq('foo')
|
13
14
|
end
|
14
15
|
|
15
|
-
it
|
16
|
+
it 'should return nil when no subdomain' do
|
16
17
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'bar.com')
|
17
18
|
expect(elevator.parse_tenant_name(request)).to be_nil
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
context
|
22
|
-
it
|
22
|
+
context 'assuming two tlds' do
|
23
|
+
it 'should parse subdomain in the third level domain' do
|
23
24
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.bar.co.uk')
|
24
|
-
expect(elevator.parse_tenant_name(request)).to eq(
|
25
|
+
expect(elevator.parse_tenant_name(request)).to eq('foo')
|
25
26
|
end
|
26
27
|
|
27
|
-
it
|
28
|
+
it 'should return nil when no subdomain in the third level domain' do
|
28
29
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'bar.co.uk')
|
29
30
|
expect(elevator.parse_tenant_name(request)).to be_nil
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
context
|
34
|
-
it
|
34
|
+
context 'assuming two subdomains' do
|
35
|
+
it 'should parse two subdomains in the two level domain' do
|
35
36
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.xyz.bar.com')
|
36
|
-
expect(elevator.parse_tenant_name(request)).to eq(
|
37
|
+
expect(elevator.parse_tenant_name(request)).to eq('foo')
|
37
38
|
end
|
38
39
|
|
39
|
-
it
|
40
|
+
it 'should parse two subdomains in the third level domain' do
|
40
41
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'foo.xyz.bar.co.uk')
|
41
|
-
expect(elevator.parse_tenant_name(request)).to eq(
|
42
|
+
expect(elevator.parse_tenant_name(request)).to eq('foo')
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
context
|
46
|
-
it
|
46
|
+
context 'assuming localhost' do
|
47
|
+
it 'should return nil for localhost' do
|
47
48
|
request = ActionDispatch::Request.new('HTTP_HOST' => 'localhost')
|
48
49
|
expect(elevator.parse_tenant_name(request)).to be_nil
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
|
-
context
|
53
|
-
it
|
53
|
+
context 'assuming ip address' do
|
54
|
+
it 'should return nil for an ip address' do
|
54
55
|
request = ActionDispatch::Request.new('HTTP_HOST' => '127.0.0.1')
|
55
56
|
expect(elevator.parse_tenant_name(request)).to be_nil
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
|
-
describe
|
61
|
-
it
|
61
|
+
describe '#call' do
|
62
|
+
it 'switches to the proper tenant' do
|
62
63
|
expect(Apartment::Tenant).to receive(:switch).with('tenant1')
|
63
64
|
elevator.call('HTTP_HOST' => 'tenant1.example.com')
|
64
65
|
end
|
65
66
|
|
66
|
-
it
|
67
|
-
described_class.excluded_subdomains = %w
|
67
|
+
it 'ignores excluded subdomains' do
|
68
|
+
described_class.excluded_subdomains = %w[foo]
|
68
69
|
|
69
70
|
expect(Apartment::Tenant).not_to receive(:switch)
|
70
71
|
|
data/spec/unit/migrator_spec.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'apartment/migrator'
|
3
5
|
|
4
6
|
describe Apartment::Migrator do
|
5
|
-
|
6
|
-
let(:tenant){ Apartment::Test.next_db }
|
7
|
+
let(:tenant) { Apartment::Test.next_db }
|
7
8
|
|
8
9
|
# Don't need a real switch here, just testing behaviour
|
9
10
|
before { allow(Apartment::Tenant.adapter).to receive(:connect_to_new) }
|
10
11
|
|
11
|
-
context
|
12
|
+
context 'with ActiveRecord below 5.2.0', skip: ActiveRecord.version >= Gem::Version.new('5.2.0') do
|
12
13
|
before do
|
13
|
-
allow(ActiveRecord::Migrator).to receive(:migrations_paths) { %w
|
14
|
+
allow(ActiveRecord::Migrator).to receive(:migrations_paths) { %w[spec/dummy/db/migrate] }
|
14
15
|
allow(Apartment::Migrator).to receive(:activerecord_below_5_2?) { true }
|
15
16
|
end
|
16
17
|
|
17
|
-
describe
|
18
|
-
it
|
18
|
+
describe '::migrate' do
|
19
|
+
it 'switches and migrates' do
|
19
20
|
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
20
21
|
expect(ActiveRecord::Migrator).to receive(:migrate)
|
21
22
|
|
@@ -23,8 +24,8 @@ describe Apartment::Migrator do
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
describe
|
27
|
-
it
|
27
|
+
describe '::run' do
|
28
|
+
it 'switches and runs' do
|
28
29
|
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
29
30
|
expect(ActiveRecord::Migrator).to receive(:run).with(:up, anything, 1234)
|
30
31
|
|
@@ -32,8 +33,8 @@ describe Apartment::Migrator do
|
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|
35
|
-
describe
|
36
|
-
it
|
36
|
+
describe '::rollback' do
|
37
|
+
it 'switches and rolls back' do
|
37
38
|
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
38
39
|
expect(ActiveRecord::Migrator).to receive(:rollback).with(anything, 2)
|
39
40
|
|
@@ -42,13 +43,13 @@ describe Apartment::Migrator do
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
context
|
46
|
+
context 'with ActiveRecord above or equal to 5.2.0', skip: ActiveRecord.version < Gem::Version.new('5.2.0') do
|
46
47
|
before do
|
47
48
|
allow(Apartment::Migrator).to receive(:activerecord_below_5_2?) { false }
|
48
49
|
end
|
49
50
|
|
50
|
-
describe
|
51
|
-
it
|
51
|
+
describe '::migrate' do
|
52
|
+
it 'switches and migrates' do
|
52
53
|
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
53
54
|
expect_any_instance_of(ActiveRecord::MigrationContext).to receive(:migrate)
|
54
55
|
|
@@ -56,8 +57,8 @@ describe Apartment::Migrator do
|
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
|
-
describe
|
60
|
-
it
|
60
|
+
describe '::run' do
|
61
|
+
it 'switches and runs' do
|
61
62
|
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
62
63
|
expect_any_instance_of(ActiveRecord::MigrationContext).to receive(:run).with(:up, 1234)
|
63
64
|
|
@@ -65,8 +66,8 @@ describe Apartment::Migrator do
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
|
-
describe
|
69
|
-
it
|
69
|
+
describe '::rollback' do
|
70
|
+
it 'switches and rolls back' do
|
70
71
|
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
71
72
|
expect_any_instance_of(ActiveRecord::MigrationContext).to receive(:rollback).with(2)
|
72
73
|
|
data/spec/unit/reloader_spec.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Apartment::Reloader do
|
4
|
-
|
5
|
-
context "using postgresql schemas" do
|
6
|
-
|
6
|
+
context 'using postgresql schemas' do
|
7
7
|
before do
|
8
8
|
Apartment.configure do |config|
|
9
|
-
config.excluded_models = [
|
9
|
+
config.excluded_models = ['Company']
|
10
10
|
config.use_schemas = true
|
11
11
|
end
|
12
12
|
Apartment::Tenant.reload!(config)
|
13
|
-
Company.reset_table_name
|
13
|
+
Company.reset_table_name # ensure we're clean
|
14
14
|
end
|
15
15
|
|
16
|
-
subject{ Apartment::Reloader.new(double(
|
16
|
+
subject { Apartment::Reloader.new(double('Rack::Application', call: nil)) }
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'should initialize apartment when called' do
|
19
19
|
expect(Company.table_name).not_to include('public.')
|
20
20
|
subject.call(double('env'))
|
21
21
|
expect(Company.table_name).to include('public.')
|
22
22
|
end
|
23
23
|
end
|
24
|
-
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ros-apartment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brunner
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-01
|
13
|
+
date: 2020-04-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -36,30 +36,36 @@ dependencies:
|
|
36
36
|
name: parallel
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - "<"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0
|
41
|
+
version: '2.0'
|
42
42
|
type: :runtime
|
43
43
|
prerelease: false
|
44
44
|
version_requirements: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "<"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0
|
48
|
+
version: '2.0'
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: public_suffix
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 2.0.5
|
56
|
+
- - "<"
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '5.0'
|
56
59
|
type: :runtime
|
57
60
|
prerelease: false
|
58
61
|
version_requirements: !ruby/object:Gem::Requirement
|
59
62
|
requirements:
|
60
63
|
- - ">="
|
61
64
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
65
|
+
version: 2.0.5
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
63
69
|
- !ruby/object:Gem::Dependency
|
64
70
|
name: rack
|
65
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,6 +73,9 @@ dependencies:
|
|
67
73
|
- - ">="
|
68
74
|
- !ruby/object:Gem::Version
|
69
75
|
version: 1.3.6
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '3.0'
|
70
79
|
type: :runtime
|
71
80
|
prerelease: false
|
72
81
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,20 +83,23 @@ dependencies:
|
|
74
83
|
- - ">="
|
75
84
|
- !ruby/object:Gem::Version
|
76
85
|
version: 1.3.6
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3.0'
|
77
89
|
- !ruby/object:Gem::Dependency
|
78
90
|
name: appraisal
|
79
91
|
requirement: !ruby/object:Gem::Requirement
|
80
92
|
requirements:
|
81
|
-
- - "
|
93
|
+
- - "~>"
|
82
94
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
95
|
+
version: '2.2'
|
84
96
|
type: :development
|
85
97
|
prerelease: false
|
86
98
|
version_requirements: !ruby/object:Gem::Requirement
|
87
99
|
requirements:
|
88
|
-
- - "
|
100
|
+
- - "~>"
|
89
101
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
102
|
+
version: '2.2'
|
91
103
|
- !ruby/object:Gem::Dependency
|
92
104
|
name: bundler
|
93
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,30 +180,30 @@ dependencies:
|
|
168
180
|
name: mysql2
|
169
181
|
requirement: !ruby/object:Gem::Requirement
|
170
182
|
requirements:
|
171
|
-
- - "
|
183
|
+
- - "~>"
|
172
184
|
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
185
|
+
version: '0.5'
|
174
186
|
type: :development
|
175
187
|
prerelease: false
|
176
188
|
version_requirements: !ruby/object:Gem::Requirement
|
177
189
|
requirements:
|
178
|
-
- - "
|
190
|
+
- - "~>"
|
179
191
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
192
|
+
version: '0.5'
|
181
193
|
- !ruby/object:Gem::Dependency
|
182
194
|
name: pg
|
183
195
|
requirement: !ruby/object:Gem::Requirement
|
184
196
|
requirements:
|
185
|
-
- - "
|
197
|
+
- - "~>"
|
186
198
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
199
|
+
version: '1.2'
|
188
200
|
type: :development
|
189
201
|
prerelease: false
|
190
202
|
version_requirements: !ruby/object:Gem::Requirement
|
191
203
|
requirements:
|
192
|
-
- - "
|
204
|
+
- - "~>"
|
193
205
|
- !ruby/object:Gem::Version
|
194
|
-
version: '
|
206
|
+
version: '1.2'
|
195
207
|
- !ruby/object:Gem::Dependency
|
196
208
|
name: sqlite3
|
197
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,9 +229,13 @@ extensions: []
|
|
217
229
|
extra_rdoc_files: []
|
218
230
|
files:
|
219
231
|
- ".github/ISSUE_TEMPLATE.md"
|
232
|
+
- ".github/workflows/.rubocop-linter.yml"
|
220
233
|
- ".gitignore"
|
221
234
|
- ".pryrc"
|
222
235
|
- ".rspec"
|
236
|
+
- ".rubocop.yml"
|
237
|
+
- ".rubocop_todo.yml"
|
238
|
+
- ".story_branch.yml"
|
223
239
|
- ".travis.yml"
|
224
240
|
- Appraisals
|
225
241
|
- Gemfile
|
@@ -246,6 +262,7 @@ files:
|
|
246
262
|
- lib/apartment/adapters/postgresql_adapter.rb
|
247
263
|
- lib/apartment/adapters/sqlite3_adapter.rb
|
248
264
|
- lib/apartment/console.rb
|
265
|
+
- lib/apartment/custom_console.rb
|
249
266
|
- lib/apartment/deprecation.rb
|
250
267
|
- lib/apartment/elevators/domain.rb
|
251
268
|
- lib/apartment/elevators/first_subdomain.rb
|
@@ -273,6 +290,7 @@ files:
|
|
273
290
|
- spec/dummy/Rakefile
|
274
291
|
- spec/dummy/app/controllers/application_controller.rb
|
275
292
|
- spec/dummy/app/helpers/application_helper.rb
|
293
|
+
- spec/dummy/app/models/application_record.rb
|
276
294
|
- spec/dummy/app/models/company.rb
|
277
295
|
- spec/dummy/app/models/user.rb
|
278
296
|
- spec/dummy/app/views/application/index.html.erb
|
@@ -382,8 +400,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
382
400
|
- !ruby/object:Gem::Version
|
383
401
|
version: '0'
|
384
402
|
requirements: []
|
385
|
-
|
386
|
-
rubygems_version: 2.7.6
|
403
|
+
rubygems_version: 3.0.3
|
387
404
|
signing_key:
|
388
405
|
specification_version: 4
|
389
406
|
summary: A Ruby gem for managing database multitenancy. Apartment Gem drop in replacement
|
@@ -398,6 +415,7 @@ test_files:
|
|
398
415
|
- spec/dummy/Rakefile
|
399
416
|
- spec/dummy/app/controllers/application_controller.rb
|
400
417
|
- spec/dummy/app/helpers/application_helper.rb
|
418
|
+
- spec/dummy/app/models/application_record.rb
|
401
419
|
- spec/dummy/app/models/company.rb
|
402
420
|
- spec/dummy/app/models/user.rb
|
403
421
|
- spec/dummy/app/views/application/index.html.erb
|