ros-apartment 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.travis.yml +8 -30
- data/Appraisals +4 -17
- data/Gemfile +1 -1
- data/Guardfile +3 -1
- data/README.md +15 -14
- data/Rakefile +34 -22
- data/apartment.gemspec +11 -3
- data/gemfiles/rails_5_0.gemfile +10 -11
- data/gemfiles/rails_5_1.gemfile +10 -11
- data/gemfiles/rails_5_2.gemfile +9 -10
- data/gemfiles/rails_6_0.gemfile +10 -11
- data/gemfiles/rails_master.gemfile +10 -11
- data/lib/apartment/active_record/connection_handling.rb +17 -0
- data/lib/apartment/active_record/internal_metadata.rb +11 -0
- data/lib/apartment/active_record/schema_migration.rb +13 -0
- data/lib/apartment/adapters/abstract_adapter.rb +3 -2
- data/lib/apartment/model.rb +27 -0
- data/lib/apartment/tenant.rb +3 -1
- data/lib/apartment/version.rb +1 -1
- data/lib/apartment.rb +22 -3
- metadata +11 -209
- data/spec/adapters/jdbc_mysql_adapter_spec.rb +0 -20
- data/spec/adapters/jdbc_postgresql_adapter_spec.rb +0 -39
- data/spec/adapters/mysql2_adapter_spec.rb +0 -61
- data/spec/adapters/postgresql_adapter_spec.rb +0 -63
- data/spec/adapters/sqlite3_adapter_spec.rb +0 -101
- data/spec/apartment_spec.rb +0 -13
- data/spec/config/database.yml.sample +0 -49
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/controllers/application_controller.rb +0 -7
- data/spec/dummy/app/helpers/application_helper.rb +0 -4
- data/spec/dummy/app/models/application_record.rb +0 -6
- data/spec/dummy/app/models/company.rb +0 -5
- data/spec/dummy/app/models/user.rb +0 -5
- data/spec/dummy/app/views/application/index.html.erb +0 -1
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/config/application.rb +0 -51
- data/spec/dummy/config/boot.rb +0 -13
- data/spec/dummy/config/database.yml.sample +0 -44
- data/spec/dummy/config/environment.rb +0 -7
- data/spec/dummy/config/environments/development.rb +0 -29
- data/spec/dummy/config/environments/production.rb +0 -53
- data/spec/dummy/config/environments/test.rb +0 -36
- data/spec/dummy/config/initializers/apartment.rb +0 -6
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -8
- data/spec/dummy/config/initializers/inflections.rb +0 -11
- data/spec/dummy/config/initializers/mime_types.rb +0 -6
- data/spec/dummy/config/initializers/secret_token.rb +0 -9
- data/spec/dummy/config/initializers/session_store.rb +0 -10
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -5
- data/spec/dummy/config.ru +0 -6
- data/spec/dummy/db/migrate/20110613152810_create_dummy_models.rb +0 -39
- data/spec/dummy/db/migrate/20111202022214_create_table_books.rb +0 -14
- data/spec/dummy/db/migrate/20180415260934_create_public_tokens.rb +0 -13
- data/spec/dummy/db/schema.rb +0 -55
- data/spec/dummy/db/seeds/import.rb +0 -7
- data/spec/dummy/db/seeds.rb +0 -5
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +0 -26
- data/spec/dummy/public/422.html +0 -26
- data/spec/dummy/public/500.html +0 -26
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +0 -8
- data/spec/dummy_engine/.gitignore +0 -8
- data/spec/dummy_engine/Gemfile +0 -15
- data/spec/dummy_engine/Rakefile +0 -34
- data/spec/dummy_engine/bin/rails +0 -12
- data/spec/dummy_engine/config/initializers/apartment.rb +0 -52
- data/spec/dummy_engine/dummy_engine.gemspec +0 -24
- data/spec/dummy_engine/lib/dummy_engine/engine.rb +0 -6
- data/spec/dummy_engine/lib/dummy_engine/version.rb +0 -5
- data/spec/dummy_engine/lib/dummy_engine.rb +0 -6
- data/spec/dummy_engine/test/dummy/Rakefile +0 -6
- data/spec/dummy_engine/test/dummy/config/application.rb +0 -24
- data/spec/dummy_engine/test/dummy/config/boot.rb +0 -7
- data/spec/dummy_engine/test/dummy/config/database.yml +0 -25
- data/spec/dummy_engine/test/dummy/config/environment.rb +0 -7
- data/spec/dummy_engine/test/dummy/config/environments/development.rb +0 -39
- data/spec/dummy_engine/test/dummy/config/environments/production.rb +0 -80
- data/spec/dummy_engine/test/dummy/config/environments/test.rb +0 -41
- data/spec/dummy_engine/test/dummy/config/initializers/assets.rb +0 -10
- data/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb +0 -8
- data/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb +0 -6
- data/spec/dummy_engine/test/dummy/config/initializers/inflections.rb +0 -17
- data/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy_engine/test/dummy/config/initializers/session_store.rb +0 -5
- data/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb +0 -16
- data/spec/dummy_engine/test/dummy/config/locales/en.yml +0 -23
- data/spec/dummy_engine/test/dummy/config/routes.rb +0 -58
- data/spec/dummy_engine/test/dummy/config/secrets.yml +0 -22
- data/spec/dummy_engine/test/dummy/config.ru +0 -6
- data/spec/examples/connection_adapter_examples.rb +0 -44
- data/spec/examples/generic_adapter_custom_configuration_example.rb +0 -93
- data/spec/examples/generic_adapter_examples.rb +0 -164
- data/spec/examples/schema_adapter_examples.rb +0 -239
- data/spec/integration/apartment_rake_integration_spec.rb +0 -107
- data/spec/integration/query_caching_spec.rb +0 -83
- data/spec/integration/use_within_an_engine_spec.rb +0 -28
- data/spec/schemas/v1.rb +0 -15
- data/spec/schemas/v2.rb +0 -41
- data/spec/schemas/v3.rb +0 -47
- data/spec/spec_helper.rb +0 -63
- data/spec/support/apartment_helpers.rb +0 -47
- data/spec/support/capybara_sessions.rb +0 -15
- data/spec/support/config.rb +0 -13
- data/spec/support/contexts.rb +0 -54
- data/spec/support/requirements.rb +0 -48
- data/spec/support/setup.rb +0 -46
- data/spec/tasks/apartment_rake_spec.rb +0 -124
- data/spec/tenant_spec.rb +0 -194
- data/spec/unit/config_spec.rb +0 -111
- data/spec/unit/elevators/domain_spec.rb +0 -33
- data/spec/unit/elevators/first_subdomain_spec.rb +0 -26
- data/spec/unit/elevators/generic_spec.rb +0 -55
- data/spec/unit/elevators/host_hash_spec.rb +0 -33
- data/spec/unit/elevators/host_spec.rb +0 -89
- data/spec/unit/elevators/subdomain_spec.rb +0 -77
- data/spec/unit/migrator_spec.rb +0 -78
- data/spec/unit/reloader_spec.rb +0 -24
data/spec/unit/migrator_spec.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'apartment/migrator'
|
5
|
-
|
6
|
-
describe Apartment::Migrator do
|
7
|
-
let(:tenant) { Apartment::Test.next_db }
|
8
|
-
|
9
|
-
# Don't need a real switch here, just testing behaviour
|
10
|
-
before { allow(Apartment::Tenant.adapter).to receive(:connect_to_new) }
|
11
|
-
|
12
|
-
context 'with ActiveRecord below 5.2.0', skip: ActiveRecord.version >= Gem::Version.new('5.2.0') do
|
13
|
-
before do
|
14
|
-
allow(ActiveRecord::Migrator).to receive(:migrations_paths) { %w[spec/dummy/db/migrate] }
|
15
|
-
allow(Apartment::Migrator).to receive(:activerecord_below_5_2?) { true }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '::migrate' do
|
19
|
-
it 'switches and migrates' do
|
20
|
-
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
21
|
-
expect(ActiveRecord::Migrator).to receive(:migrate)
|
22
|
-
|
23
|
-
Apartment::Migrator.migrate(tenant)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '::run' do
|
28
|
-
it 'switches and runs' do
|
29
|
-
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
30
|
-
expect(ActiveRecord::Migrator).to receive(:run).with(:up, anything, 1234)
|
31
|
-
|
32
|
-
Apartment::Migrator.run(:up, tenant, 1234)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '::rollback' do
|
37
|
-
it 'switches and rolls back' do
|
38
|
-
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
39
|
-
expect(ActiveRecord::Migrator).to receive(:rollback).with(anything, 2)
|
40
|
-
|
41
|
-
Apartment::Migrator.rollback(tenant, 2)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'with ActiveRecord above or equal to 5.2.0', skip: ActiveRecord.version < Gem::Version.new('5.2.0') do
|
47
|
-
before do
|
48
|
-
allow(Apartment::Migrator).to receive(:activerecord_below_5_2?) { false }
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '::migrate' do
|
52
|
-
it 'switches and migrates' do
|
53
|
-
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
54
|
-
expect_any_instance_of(ActiveRecord::MigrationContext).to receive(:migrate)
|
55
|
-
|
56
|
-
Apartment::Migrator.migrate(tenant)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe '::run' do
|
61
|
-
it 'switches and runs' do
|
62
|
-
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
63
|
-
expect_any_instance_of(ActiveRecord::MigrationContext).to receive(:run).with(:up, 1234)
|
64
|
-
|
65
|
-
Apartment::Migrator.run(:up, tenant, 1234)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '::rollback' do
|
70
|
-
it 'switches and rolls back' do
|
71
|
-
expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
|
72
|
-
expect_any_instance_of(ActiveRecord::MigrationContext).to receive(:rollback).with(2)
|
73
|
-
|
74
|
-
Apartment::Migrator.rollback(tenant, 2)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/spec/unit/reloader_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Apartment::Reloader do
|
6
|
-
context 'using postgresql schemas' do
|
7
|
-
before do
|
8
|
-
Apartment.configure do |config|
|
9
|
-
config.excluded_models = ['Company']
|
10
|
-
config.use_schemas = true
|
11
|
-
end
|
12
|
-
Apartment::Tenant.reload!(config)
|
13
|
-
Company.reset_table_name # ensure we're clean
|
14
|
-
end
|
15
|
-
|
16
|
-
subject { Apartment::Reloader.new(double('Rack::Application', call: nil)) }
|
17
|
-
|
18
|
-
it 'should initialize apartment when called' do
|
19
|
-
expect(Company.table_name).not_to include('public.')
|
20
|
-
subject.call(double('env'))
|
21
|
-
expect(Company.table_name).to include('public.')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|