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.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.travis.yml +8 -30
  4. data/Appraisals +4 -17
  5. data/Gemfile +1 -1
  6. data/Guardfile +3 -1
  7. data/README.md +15 -14
  8. data/Rakefile +34 -22
  9. data/apartment.gemspec +11 -3
  10. data/gemfiles/rails_5_0.gemfile +10 -11
  11. data/gemfiles/rails_5_1.gemfile +10 -11
  12. data/gemfiles/rails_5_2.gemfile +9 -10
  13. data/gemfiles/rails_6_0.gemfile +10 -11
  14. data/gemfiles/rails_master.gemfile +10 -11
  15. data/lib/apartment/active_record/connection_handling.rb +17 -0
  16. data/lib/apartment/active_record/internal_metadata.rb +11 -0
  17. data/lib/apartment/active_record/schema_migration.rb +13 -0
  18. data/lib/apartment/adapters/abstract_adapter.rb +3 -2
  19. data/lib/apartment/model.rb +27 -0
  20. data/lib/apartment/tenant.rb +3 -1
  21. data/lib/apartment/version.rb +1 -1
  22. data/lib/apartment.rb +22 -3
  23. metadata +11 -209
  24. data/spec/adapters/jdbc_mysql_adapter_spec.rb +0 -20
  25. data/spec/adapters/jdbc_postgresql_adapter_spec.rb +0 -39
  26. data/spec/adapters/mysql2_adapter_spec.rb +0 -61
  27. data/spec/adapters/postgresql_adapter_spec.rb +0 -63
  28. data/spec/adapters/sqlite3_adapter_spec.rb +0 -101
  29. data/spec/apartment_spec.rb +0 -13
  30. data/spec/config/database.yml.sample +0 -49
  31. data/spec/dummy/Rakefile +0 -7
  32. data/spec/dummy/app/controllers/application_controller.rb +0 -7
  33. data/spec/dummy/app/helpers/application_helper.rb +0 -4
  34. data/spec/dummy/app/models/application_record.rb +0 -6
  35. data/spec/dummy/app/models/company.rb +0 -5
  36. data/spec/dummy/app/models/user.rb +0 -5
  37. data/spec/dummy/app/views/application/index.html.erb +0 -1
  38. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  39. data/spec/dummy/config/application.rb +0 -51
  40. data/spec/dummy/config/boot.rb +0 -13
  41. data/spec/dummy/config/database.yml.sample +0 -44
  42. data/spec/dummy/config/environment.rb +0 -7
  43. data/spec/dummy/config/environments/development.rb +0 -29
  44. data/spec/dummy/config/environments/production.rb +0 -53
  45. data/spec/dummy/config/environments/test.rb +0 -36
  46. data/spec/dummy/config/initializers/apartment.rb +0 -6
  47. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -8
  48. data/spec/dummy/config/initializers/inflections.rb +0 -11
  49. data/spec/dummy/config/initializers/mime_types.rb +0 -6
  50. data/spec/dummy/config/initializers/secret_token.rb +0 -9
  51. data/spec/dummy/config/initializers/session_store.rb +0 -10
  52. data/spec/dummy/config/locales/en.yml +0 -5
  53. data/spec/dummy/config/routes.rb +0 -5
  54. data/spec/dummy/config.ru +0 -6
  55. data/spec/dummy/db/migrate/20110613152810_create_dummy_models.rb +0 -39
  56. data/spec/dummy/db/migrate/20111202022214_create_table_books.rb +0 -14
  57. data/spec/dummy/db/migrate/20180415260934_create_public_tokens.rb +0 -13
  58. data/spec/dummy/db/schema.rb +0 -55
  59. data/spec/dummy/db/seeds/import.rb +0 -7
  60. data/spec/dummy/db/seeds.rb +0 -5
  61. data/spec/dummy/db/test.sqlite3 +0 -0
  62. data/spec/dummy/public/404.html +0 -26
  63. data/spec/dummy/public/422.html +0 -26
  64. data/spec/dummy/public/500.html +0 -26
  65. data/spec/dummy/public/favicon.ico +0 -0
  66. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  67. data/spec/dummy/script/rails +0 -8
  68. data/spec/dummy_engine/.gitignore +0 -8
  69. data/spec/dummy_engine/Gemfile +0 -15
  70. data/spec/dummy_engine/Rakefile +0 -34
  71. data/spec/dummy_engine/bin/rails +0 -12
  72. data/spec/dummy_engine/config/initializers/apartment.rb +0 -52
  73. data/spec/dummy_engine/dummy_engine.gemspec +0 -24
  74. data/spec/dummy_engine/lib/dummy_engine/engine.rb +0 -6
  75. data/spec/dummy_engine/lib/dummy_engine/version.rb +0 -5
  76. data/spec/dummy_engine/lib/dummy_engine.rb +0 -6
  77. data/spec/dummy_engine/test/dummy/Rakefile +0 -6
  78. data/spec/dummy_engine/test/dummy/config/application.rb +0 -24
  79. data/spec/dummy_engine/test/dummy/config/boot.rb +0 -7
  80. data/spec/dummy_engine/test/dummy/config/database.yml +0 -25
  81. data/spec/dummy_engine/test/dummy/config/environment.rb +0 -7
  82. data/spec/dummy_engine/test/dummy/config/environments/development.rb +0 -39
  83. data/spec/dummy_engine/test/dummy/config/environments/production.rb +0 -80
  84. data/spec/dummy_engine/test/dummy/config/environments/test.rb +0 -41
  85. data/spec/dummy_engine/test/dummy/config/initializers/assets.rb +0 -10
  86. data/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb +0 -8
  87. data/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  88. data/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb +0 -6
  89. data/spec/dummy_engine/test/dummy/config/initializers/inflections.rb +0 -17
  90. data/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb +0 -5
  91. data/spec/dummy_engine/test/dummy/config/initializers/session_store.rb +0 -5
  92. data/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb +0 -16
  93. data/spec/dummy_engine/test/dummy/config/locales/en.yml +0 -23
  94. data/spec/dummy_engine/test/dummy/config/routes.rb +0 -58
  95. data/spec/dummy_engine/test/dummy/config/secrets.yml +0 -22
  96. data/spec/dummy_engine/test/dummy/config.ru +0 -6
  97. data/spec/examples/connection_adapter_examples.rb +0 -44
  98. data/spec/examples/generic_adapter_custom_configuration_example.rb +0 -93
  99. data/spec/examples/generic_adapter_examples.rb +0 -164
  100. data/spec/examples/schema_adapter_examples.rb +0 -239
  101. data/spec/integration/apartment_rake_integration_spec.rb +0 -107
  102. data/spec/integration/query_caching_spec.rb +0 -83
  103. data/spec/integration/use_within_an_engine_spec.rb +0 -28
  104. data/spec/schemas/v1.rb +0 -15
  105. data/spec/schemas/v2.rb +0 -41
  106. data/spec/schemas/v3.rb +0 -47
  107. data/spec/spec_helper.rb +0 -63
  108. data/spec/support/apartment_helpers.rb +0 -47
  109. data/spec/support/capybara_sessions.rb +0 -15
  110. data/spec/support/config.rb +0 -13
  111. data/spec/support/contexts.rb +0 -54
  112. data/spec/support/requirements.rb +0 -48
  113. data/spec/support/setup.rb +0 -46
  114. data/spec/tasks/apartment_rake_spec.rb +0 -124
  115. data/spec/tenant_spec.rb +0 -194
  116. data/spec/unit/config_spec.rb +0 -111
  117. data/spec/unit/elevators/domain_spec.rb +0 -33
  118. data/spec/unit/elevators/first_subdomain_spec.rb +0 -26
  119. data/spec/unit/elevators/generic_spec.rb +0 -55
  120. data/spec/unit/elevators/host_hash_spec.rb +0 -33
  121. data/spec/unit/elevators/host_spec.rb +0 -89
  122. data/spec/unit/elevators/subdomain_spec.rb +0 -77
  123. data/spec/unit/migrator_spec.rb +0 -78
  124. data/spec/unit/reloader_spec.rb +0 -24
@@ -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
@@ -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