ros-apartment 2.3.0 → 2.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +78 -0
  3. data/.github/workflows/changelog.yml +63 -0
  4. data/.github/workflows/reviewdog.yml +22 -0
  5. data/.pryrc +5 -3
  6. data/.rubocop.yml +32 -0
  7. data/.rubocop_todo.yml +233 -0
  8. data/.ruby-version +1 -0
  9. data/.story_branch.yml +5 -0
  10. data/Appraisals +29 -42
  11. data/CHANGELOG.md +963 -0
  12. data/Gemfile +2 -7
  13. data/Guardfile +3 -16
  14. data/HISTORY.md +159 -68
  15. data/README.md +101 -21
  16. data/Rakefile +39 -22
  17. data/TODO.md +0 -1
  18. data/gemfiles/rails_5_2.gemfile +0 -5
  19. data/gemfiles/rails_6_0.gemfile +4 -9
  20. data/gemfiles/rails_6_1.gemfile +17 -0
  21. data/gemfiles/rails_7_0.gemfile +17 -0
  22. data/gemfiles/rails_master.gemfile +3 -8
  23. data/lib/apartment/active_record/connection_handling.rb +20 -0
  24. data/lib/apartment/active_record/internal_metadata.rb +9 -0
  25. data/lib/apartment/active_record/postgresql_adapter.rb +39 -0
  26. data/lib/apartment/active_record/schema_migration.rb +11 -0
  27. data/lib/apartment/adapters/abstract_adapter.rb +52 -46
  28. data/lib/apartment/adapters/abstract_jdbc_adapter.rb +5 -3
  29. data/lib/apartment/adapters/jdbc_mysql_adapter.rb +3 -3
  30. data/lib/apartment/adapters/jdbc_postgresql_adapter.rb +19 -13
  31. data/lib/apartment/adapters/mysql2_adapter.rb +15 -9
  32. data/lib/apartment/adapters/postgis_adapter.rb +3 -2
  33. data/lib/apartment/adapters/postgresql_adapter.rb +79 -31
  34. data/lib/apartment/adapters/sqlite3_adapter.rb +18 -8
  35. data/lib/apartment/console.rb +23 -11
  36. data/lib/apartment/custom_console.rb +42 -0
  37. data/lib/apartment/deprecation.rb +2 -1
  38. data/lib/apartment/elevators/domain.rb +4 -3
  39. data/lib/apartment/elevators/first_subdomain.rb +3 -2
  40. data/lib/apartment/elevators/generic.rb +4 -3
  41. data/lib/apartment/elevators/host.rb +6 -1
  42. data/lib/apartment/elevators/host_hash.rb +6 -2
  43. data/lib/apartment/elevators/subdomain.rb +9 -5
  44. data/lib/apartment/log_subscriber.rb +33 -0
  45. data/lib/apartment/migrator.rb +4 -3
  46. data/lib/apartment/model.rb +29 -0
  47. data/lib/apartment/railtie.rb +16 -20
  48. data/lib/apartment/tasks/enhancements.rb +4 -6
  49. data/lib/apartment/tasks/task_helper.rb +52 -0
  50. data/lib/apartment/tenant.rb +7 -10
  51. data/lib/apartment/version.rb +3 -1
  52. data/lib/apartment.rb +56 -15
  53. data/lib/generators/apartment/install/install_generator.rb +4 -3
  54. data/lib/generators/apartment/install/templates/apartment.rb +10 -3
  55. data/lib/tasks/apartment.rake +48 -87
  56. data/ros-apartment.gemspec +59 -0
  57. metadata +148 -240
  58. data/.travis.yml +0 -65
  59. data/apartment.gemspec +0 -47
  60. data/gemfiles/rails_4_2.gemfile +0 -23
  61. data/gemfiles/rails_5_0.gemfile +0 -22
  62. data/gemfiles/rails_5_1.gemfile +0 -22
  63. data/lib/apartment/reloader.rb +0 -21
  64. data/spec/adapters/jdbc_mysql_adapter_spec.rb +0 -19
  65. data/spec/adapters/jdbc_postgresql_adapter_spec.rb +0 -41
  66. data/spec/adapters/mysql2_adapter_spec.rb +0 -59
  67. data/spec/adapters/postgresql_adapter_spec.rb +0 -61
  68. data/spec/adapters/sqlite3_adapter_spec.rb +0 -83
  69. data/spec/apartment_spec.rb +0 -11
  70. data/spec/config/database.yml.sample +0 -49
  71. data/spec/dummy/Rakefile +0 -7
  72. data/spec/dummy/app/controllers/application_controller.rb +0 -6
  73. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  74. data/spec/dummy/app/models/company.rb +0 -3
  75. data/spec/dummy/app/models/user.rb +0 -3
  76. data/spec/dummy/app/views/application/index.html.erb +0 -1
  77. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  78. data/spec/dummy/config/application.rb +0 -49
  79. data/spec/dummy/config/boot.rb +0 -11
  80. data/spec/dummy/config/database.yml.sample +0 -44
  81. data/spec/dummy/config/environment.rb +0 -5
  82. data/spec/dummy/config/environments/development.rb +0 -28
  83. data/spec/dummy/config/environments/production.rb +0 -51
  84. data/spec/dummy/config/environments/test.rb +0 -34
  85. data/spec/dummy/config/initializers/apartment.rb +0 -4
  86. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  87. data/spec/dummy/config/initializers/inflections.rb +0 -10
  88. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  89. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  90. data/spec/dummy/config/initializers/session_store.rb +0 -8
  91. data/spec/dummy/config/locales/en.yml +0 -5
  92. data/spec/dummy/config/routes.rb +0 -3
  93. data/spec/dummy/config.ru +0 -4
  94. data/spec/dummy/db/migrate/20110613152810_create_dummy_models.rb +0 -39
  95. data/spec/dummy/db/migrate/20111202022214_create_table_books.rb +0 -14
  96. data/spec/dummy/db/migrate/20180415260934_create_public_tokens.rb +0 -13
  97. data/spec/dummy/db/schema.rb +0 -55
  98. data/spec/dummy/db/seeds/import.rb +0 -5
  99. data/spec/dummy/db/seeds.rb +0 -5
  100. data/spec/dummy/db/test.sqlite3 +0 -0
  101. data/spec/dummy/public/404.html +0 -26
  102. data/spec/dummy/public/422.html +0 -26
  103. data/spec/dummy/public/500.html +0 -26
  104. data/spec/dummy/public/favicon.ico +0 -0
  105. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  106. data/spec/dummy/script/rails +0 -6
  107. data/spec/dummy_engine/.gitignore +0 -8
  108. data/spec/dummy_engine/Gemfile +0 -15
  109. data/spec/dummy_engine/Rakefile +0 -34
  110. data/spec/dummy_engine/bin/rails +0 -12
  111. data/spec/dummy_engine/config/initializers/apartment.rb +0 -51
  112. data/spec/dummy_engine/dummy_engine.gemspec +0 -24
  113. data/spec/dummy_engine/lib/dummy_engine/engine.rb +0 -4
  114. data/spec/dummy_engine/lib/dummy_engine/version.rb +0 -3
  115. data/spec/dummy_engine/lib/dummy_engine.rb +0 -4
  116. data/spec/dummy_engine/test/dummy/Rakefile +0 -6
  117. data/spec/dummy_engine/test/dummy/config/application.rb +0 -22
  118. data/spec/dummy_engine/test/dummy/config/boot.rb +0 -5
  119. data/spec/dummy_engine/test/dummy/config/database.yml +0 -25
  120. data/spec/dummy_engine/test/dummy/config/environment.rb +0 -5
  121. data/spec/dummy_engine/test/dummy/config/environments/development.rb +0 -37
  122. data/spec/dummy_engine/test/dummy/config/environments/production.rb +0 -78
  123. data/spec/dummy_engine/test/dummy/config/environments/test.rb +0 -39
  124. data/spec/dummy_engine/test/dummy/config/initializers/assets.rb +0 -8
  125. data/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  126. data/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  127. data/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  128. data/spec/dummy_engine/test/dummy/config/initializers/inflections.rb +0 -16
  129. data/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb +0 -4
  130. data/spec/dummy_engine/test/dummy/config/initializers/session_store.rb +0 -3
  131. data/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  132. data/spec/dummy_engine/test/dummy/config/locales/en.yml +0 -23
  133. data/spec/dummy_engine/test/dummy/config/routes.rb +0 -56
  134. data/spec/dummy_engine/test/dummy/config/secrets.yml +0 -22
  135. data/spec/dummy_engine/test/dummy/config.ru +0 -4
  136. data/spec/examples/connection_adapter_examples.rb +0 -42
  137. data/spec/examples/generic_adapter_custom_configuration_example.rb +0 -95
  138. data/spec/examples/generic_adapter_examples.rb +0 -163
  139. data/spec/examples/schema_adapter_examples.rb +0 -234
  140. data/spec/integration/apartment_rake_integration_spec.rb +0 -107
  141. data/spec/integration/query_caching_spec.rb +0 -81
  142. data/spec/integration/use_within_an_engine_spec.rb +0 -28
  143. data/spec/schemas/v1.rb +0 -16
  144. data/spec/schemas/v2.rb +0 -43
  145. data/spec/schemas/v3.rb +0 -49
  146. data/spec/spec_helper.rb +0 -61
  147. data/spec/support/apartment_helpers.rb +0 -43
  148. data/spec/support/capybara_sessions.rb +0 -15
  149. data/spec/support/config.rb +0 -10
  150. data/spec/support/contexts.rb +0 -52
  151. data/spec/support/requirements.rb +0 -35
  152. data/spec/support/setup.rb +0 -46
  153. data/spec/tasks/apartment_rake_spec.rb +0 -129
  154. data/spec/tenant_spec.rb +0 -190
  155. data/spec/unit/config_spec.rb +0 -112
  156. data/spec/unit/elevators/domain_spec.rb +0 -32
  157. data/spec/unit/elevators/first_subdomain_spec.rb +0 -24
  158. data/spec/unit/elevators/generic_spec.rb +0 -54
  159. data/spec/unit/elevators/host_hash_spec.rb +0 -32
  160. data/spec/unit/elevators/host_spec.rb +0 -89
  161. data/spec/unit/elevators/subdomain_spec.rb +0 -76
  162. data/spec/unit/migrator_spec.rb +0 -77
  163. data/spec/unit/reloader_spec.rb +0 -24
data/apartment.gemspec DELETED
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH << File.expand_path('lib', __dir__)
4
- require 'apartment/version'
5
-
6
- Gem::Specification.new do |s|
7
- s.name = 'ros-apartment'
8
- s.version = Apartment::VERSION
9
-
10
- s.authors = ['Ryan Brunner', 'Brad Robertson', 'Rui Baltazar']
11
- s.summary = 'A Ruby gem for managing database multitenancy. Apartment Gem drop in replacement'
12
- s.description = 'Apartment allows Rack applications to deal with database multitenancy through ActiveRecord'
13
- s.email = ['ryan@influitive.com', 'brad@influitive.com', 'rui.p.baltazar@gmail.com']
14
- s.files = `git ls-files`.split($/)
15
- s.executables = s.files.grep(%r{^bin/}).map { |f| File.basename(f) }
16
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
17
- s.require_paths = ['lib']
18
-
19
- s.homepage = 'https://github.com/rails-on-services/apartment'
20
- s.licenses = ['MIT']
21
-
22
- # must be >= 3.1.2 due to bug in prepared_statements
23
- s.add_dependency 'activerecord', '>= 3.1.2', '< 6.1'
24
- s.add_dependency 'parallel', '>= 0.7.1'
25
- s.add_dependency 'public_suffix', '>= 2'
26
- s.add_dependency 'rack', '>= 1.3.6'
27
-
28
- s.add_development_dependency 'appraisal'
29
- s.add_development_dependency 'bundler', '>= 1.3', '< 2.0'
30
- s.add_development_dependency 'capybara', '~> 2.0'
31
- s.add_development_dependency 'rake', '~> 0.9'
32
- s.add_development_dependency 'rspec', '~> 3.4'
33
- s.add_development_dependency 'rspec-rails', '~> 3.4'
34
-
35
- if defined?(JRUBY_VERSION)
36
- s.add_development_dependency 'activerecord-jdbc-adapter'
37
- s.add_development_dependency 'activerecord-jdbcmysql-adapter'
38
- s.add_development_dependency 'activerecord-jdbcpostgresql-adapter'
39
- s.add_development_dependency 'jdbc-mysql'
40
- s.add_development_dependency 'jdbc-postgres'
41
- s.add_development_dependency 'jruby-openssl'
42
- else
43
- s.add_development_dependency 'mysql2'
44
- s.add_development_dependency 'pg'
45
- s.add_development_dependency 'sqlite3', '~> 1.3.6'
46
- end
47
- end
@@ -1,23 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 4.2.0"
6
-
7
- group :local do
8
- gem "pry"
9
- gem "guard-rspec", "~> 4.2"
10
- end
11
-
12
- platforms :ruby do
13
- gem "pg", "< 1.0.0"
14
- gem "mysql2", "~> 0.4.0"
15
- end
16
-
17
- platforms :jruby do
18
- gem "activerecord-jdbc-adapter", "~> 1.3"
19
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3"
20
- gem "activerecord-jdbcmysql-adapter", "~> 1.3"
21
- end
22
-
23
- gemspec path: "../"
@@ -1,22 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.0"
6
-
7
- group :local do
8
- gem "pry"
9
- gem "guard-rspec", "~> 4.2"
10
- end
11
-
12
- platforms :ruby do
13
- gem "pg", "< 1.0.0"
14
- end
15
-
16
- platforms :jruby do
17
- gem "activerecord-jdbc-adapter", "~> 50.0"
18
- gem "activerecord-jdbcpostgresql-adapter", "~> 50.0"
19
- gem "activerecord-jdbcmysql-adapter", "~> 50.0"
20
- end
21
-
22
- gemspec path: "../"
@@ -1,22 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.0"
6
-
7
- group :local do
8
- gem "pry"
9
- gem "guard-rspec", "~> 4.2"
10
- end
11
-
12
- platforms :ruby do
13
- gem "pg", "< 1.0.0"
14
- end
15
-
16
- platforms :jruby do
17
- gem "activerecord-jdbc-adapter", "~> 51.0"
18
- gem "activerecord-jdbcpostgresql-adapter", "~> 51.0"
19
- gem "activerecord-jdbcmysql-adapter", "~> 51.0"
20
- end
21
-
22
- gemspec path: "../"
@@ -1,21 +0,0 @@
1
- module Apartment
2
- class Reloader
3
-
4
- # Middleware used in development to init Apartment for each request
5
- # Necessary due to code reload (annoying). When models are reloaded, they no longer have the proper table_name
6
- # That is prepended with the schema (if using postgresql schemas)
7
- # I couldn't figure out how to properly hook into the Rails reload process *after* files are reloaded
8
- # so I've used this in the meantime.
9
- #
10
- # Also see apartment/console for the re-definition of reload! that re-init's Apartment
11
- #
12
- def initialize(app)
13
- @app = app
14
- end
15
-
16
- def call(env)
17
- Tenant.init
18
- @app.call(env)
19
- end
20
- end
21
- end
@@ -1,19 +0,0 @@
1
- if defined?(JRUBY_VERSION)
2
-
3
- require 'spec_helper'
4
- require 'apartment/adapters/jdbc_mysql_adapter'
5
-
6
- describe Apartment::Adapters::JDBCMysqlAdapter, database: :mysql do
7
-
8
- subject { Apartment::Tenant.jdbc_mysql_adapter config.symbolize_keys }
9
-
10
- def tenant_names
11
- ActiveRecord::Base.connection.execute("SELECT schema_name FROM information_schema.schemata").collect { |row| row['schema_name'] }
12
- end
13
-
14
- let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.current_database } }
15
-
16
- it_should_behave_like "a generic apartment adapter"
17
- it_should_behave_like "a connection based apartment adapter"
18
- end
19
- end
@@ -1,41 +0,0 @@
1
- if defined?(JRUBY_VERSION)
2
-
3
- require 'spec_helper'
4
- require 'apartment/adapters/jdbc_postgresql_adapter'
5
-
6
- describe Apartment::Adapters::JDBCPostgresqlAdapter, database: :postgresql do
7
-
8
- subject { Apartment::Tenant.jdbc_postgresql_adapter config.symbolize_keys }
9
-
10
- context "using schemas" do
11
-
12
- before { Apartment.use_schemas = true }
13
-
14
- # Not sure why, but somehow using let(:tenant_names) memoizes for the whole example group, not just each test
15
- def tenant_names
16
- ActiveRecord::Base.connection.execute("SELECT nspname FROM pg_namespace;").collect { |row| row['nspname'] }
17
- end
18
-
19
- let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.schema_search_path.gsub('"', '') } }
20
-
21
- it_should_behave_like "a generic apartment adapter"
22
- it_should_behave_like "a schema based apartment adapter"
23
- end
24
-
25
- context "using databases" do
26
-
27
- before { Apartment.use_schemas = false }
28
-
29
- # Not sure why, but somehow using let(:tenant_names) memoizes for the whole example group, not just each test
30
- def tenant_names
31
- connection.execute("select datname from pg_database;").collect { |row| row['datname'] }
32
- end
33
-
34
- let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.current_database } }
35
-
36
- it_should_behave_like "a generic apartment adapter"
37
- it_should_behave_like "a connection based apartment adapter"
38
-
39
- end
40
- end
41
- end
@@ -1,59 +0,0 @@
1
- require 'spec_helper'
2
- require 'apartment/adapters/mysql2_adapter'
3
-
4
- describe Apartment::Adapters::Mysql2Adapter, database: :mysql do
5
- unless defined?(JRUBY_VERSION)
6
-
7
- subject(:adapter){ Apartment::Tenant.mysql2_adapter config }
8
-
9
- def tenant_names
10
- ActiveRecord::Base.connection.execute("SELECT schema_name FROM information_schema.schemata").collect { |row| row[0] }
11
- end
12
-
13
- let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.current_database } }
14
-
15
- context "using - the equivalent of - schemas" do
16
- before { Apartment.use_schemas = true }
17
-
18
- it_should_behave_like "a generic apartment adapter"
19
-
20
- describe "#default_tenant" do
21
- it "is set to the original db from config" do
22
- expect(subject.default_tenant).to eq(config[:database])
23
- end
24
- end
25
-
26
- describe "#init" do
27
- include Apartment::Spec::AdapterRequirements
28
-
29
- before do
30
- Apartment.configure do |config|
31
- config.excluded_models = ["Company"]
32
- end
33
- end
34
-
35
- after do
36
- # Apartment::Tenant.init creates per model connection.
37
- # Remove the connection after testing not to unintentionally keep the connection across tests.
38
- Apartment.excluded_models.each do |excluded_model|
39
- excluded_model.constantize.remove_connection
40
- end
41
- end
42
-
43
- it "should process model exclusions" do
44
- Apartment::Tenant.init
45
-
46
- expect(Company.table_name).to eq("#{default_tenant}.companies")
47
- end
48
- end
49
- end
50
-
51
- context "using connections" do
52
- before { Apartment.use_schemas = false }
53
-
54
- it_should_behave_like "a generic apartment adapter"
55
- it_should_behave_like "a generic apartment adapter able to handle custom configuration"
56
- it_should_behave_like "a connection based apartment adapter"
57
- end
58
- end
59
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
- require 'apartment/adapters/postgresql_adapter'
3
-
4
- describe Apartment::Adapters::PostgresqlAdapter, database: :postgresql do
5
- unless defined?(JRUBY_VERSION)
6
-
7
- subject{ Apartment::Tenant.postgresql_adapter config }
8
-
9
- context "using schemas with schema.rb" do
10
-
11
- before{ Apartment.use_schemas = true }
12
-
13
- # Not sure why, but somehow using let(:tenant_names) memoizes for the whole example group, not just each test
14
- def tenant_names
15
- ActiveRecord::Base.connection.execute("SELECT nspname FROM pg_namespace;").collect { |row| row['nspname'] }
16
- end
17
-
18
- let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.schema_search_path.gsub('"', '') } }
19
-
20
- it_should_behave_like "a generic apartment adapter"
21
- it_should_behave_like "a schema based apartment adapter"
22
- end
23
-
24
- context "using schemas with SQL dump" do
25
-
26
- before{ Apartment.use_schemas = true; Apartment.use_sql = true }
27
-
28
- # Not sure why, but somehow using let(:tenant_names) memoizes for the whole example group, not just each test
29
- def tenant_names
30
- ActiveRecord::Base.connection.execute("SELECT nspname FROM pg_namespace;").collect { |row| row['nspname'] }
31
- end
32
-
33
- let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.schema_search_path.gsub('"', '') } }
34
-
35
- it_should_behave_like "a generic apartment adapter"
36
- it_should_behave_like "a schema based apartment adapter"
37
-
38
- it 'allows for dashes in the schema name' do
39
- expect { Apartment::Tenant.create('has-dashes') }.to_not raise_error
40
- end
41
-
42
- after { Apartment::Tenant.drop('has-dashes') if Apartment.connection.schema_exists? 'has-dashes' }
43
- end
44
-
45
- context "using connections" do
46
-
47
- before{ Apartment.use_schemas = false }
48
-
49
- # Not sure why, but somehow using let(:tenant_names) memoizes for the whole example group, not just each test
50
- def tenant_names
51
- connection.execute("select datname from pg_database;").collect { |row| row['datname'] }
52
- end
53
-
54
- let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.current_database } }
55
-
56
- it_should_behave_like "a generic apartment adapter"
57
- it_should_behave_like "a generic apartment adapter able to handle custom configuration"
58
- it_should_behave_like "a connection based apartment adapter"
59
- end
60
- end
61
- end
@@ -1,83 +0,0 @@
1
- require 'spec_helper'
2
- require 'apartment/adapters/sqlite3_adapter'
3
-
4
- describe Apartment::Adapters::Sqlite3Adapter, database: :sqlite do
5
- unless defined?(JRUBY_VERSION)
6
-
7
- subject{ Apartment::Tenant.sqlite3_adapter config }
8
-
9
- context "using connections" do
10
- def tenant_names
11
- db_dir = File.expand_path("../../dummy/db", __FILE__)
12
- Dir.glob("#{db_dir}/*.sqlite3").map { |file| File.basename(file, '.sqlite3') }
13
- end
14
-
15
- let(:default_tenant) do
16
- subject.switch { File.basename(Apartment::Test.config['connections']['sqlite']['database'], '.sqlite3') }
17
- end
18
-
19
- it_should_behave_like "a generic apartment adapter"
20
- it_should_behave_like "a connection based apartment adapter"
21
-
22
- after(:all) do
23
- File.delete(Apartment::Test.config['connections']['sqlite']['database'])
24
- end
25
- end
26
-
27
- context "with prepend and append" do
28
- let(:default_dir) { File.expand_path(File.dirname(config[:database])) }
29
- describe "#prepend" do
30
- let (:db_name) { "db_with_prefix" }
31
- before do
32
- Apartment.configure do |config|
33
- config.prepend_environment = true
34
- config.append_environment = false
35
- end
36
- end
37
-
38
- after { subject.drop db_name rescue nil }
39
-
40
- it "should create a new database" do
41
- subject.create db_name
42
-
43
- expect(File.exists?("#{default_dir}/#{Rails.env}_#{db_name}.sqlite3")).to eq true
44
- end
45
- end
46
-
47
- describe "#neither" do
48
- let (:db_name) { "db_without_prefix_suffix" }
49
- before do
50
- Apartment.configure { |config| config.prepend_environment = config.append_environment = false }
51
- end
52
-
53
- after { subject.drop db_name rescue nil }
54
-
55
- it "should create a new database" do
56
- subject.create db_name
57
-
58
- expect(File.exists?("#{default_dir}/#{db_name}.sqlite3")).to eq true
59
- end
60
- end
61
-
62
- describe "#append" do
63
- let (:db_name) { "db_with_suffix" }
64
- before do
65
- Apartment.configure do |config|
66
- config.prepend_environment = false
67
- config.append_environment = true
68
- end
69
- end
70
-
71
- after { subject.drop db_name rescue nil }
72
-
73
- it "should create a new database" do
74
- subject.create db_name
75
-
76
- expect(File.exists?("#{default_dir}/#{db_name}_#{Rails.env}.sqlite3")).to eq true
77
- end
78
- end
79
-
80
- end
81
-
82
- end
83
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Apartment do
4
- it "should be valid" do
5
- expect(Apartment).to be_a(Module)
6
- end
7
-
8
- it "should be a valid app" do
9
- expect(::Rails.application).to be_a(Dummy::Application)
10
- end
11
- end
@@ -1,49 +0,0 @@
1
- <% if defined?(JRUBY_VERSION) %>
2
- connections:
3
- postgresql:
4
- adapter: postgresql
5
- database: apartment_postgresql_test
6
- username: postgres
7
- min_messages: WARNING
8
- driver: org.postgresql.Driver
9
- url: jdbc:postgresql://localhost:5432/apartment_postgresql_test
10
- timeout: 5000
11
- pool: 5
12
- host: localhost
13
- port: 5432
14
-
15
- mysql:
16
- adapter: mysql
17
- database: apartment_mysql_test
18
- username: root
19
- min_messages: WARNING
20
- driver: com.mysql.jdbc.Driver
21
- url: jdbc:mysql://localhost:3306/apartment_mysql_test
22
- timeout: 5000
23
- pool: 5
24
- host: 127.0.0.1
25
- port: 3306
26
- <% else %>
27
- connections:
28
- postgresql:
29
- adapter: postgresql
30
- database: apartment_postgresql_test
31
- min_messages: WARNING
32
- username: postgres
33
- schema_search_path: public
34
- password:
35
- host: localhost
36
- port: 5432
37
-
38
- mysql:
39
- adapter: mysql2
40
- database: apartment_mysql_test
41
- username: root
42
- password:
43
- host: 127.0.0.1
44
- port: 3306
45
-
46
- sqlite:
47
- adapter: sqlite3
48
- database: <%= File.expand_path('../spec/dummy/db', __FILE__) %>/default.sqlite3
49
- <% end %>
data/spec/dummy/Rakefile DELETED
@@ -1,7 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
- require 'rake'
6
-
7
- Dummy::Application.load_tasks
@@ -1,6 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
-
4
- def index
5
- end
6
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,3 +0,0 @@
1
- class Company < ActiveRecord::Base
2
- # Dummy models
3
- end
@@ -1,3 +0,0 @@
1
- class User < ActiveRecord::Base
2
- # Dummy models
3
- end
@@ -1 +0,0 @@
1
- <h1>Index!!</h1>
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag :all %>
6
- <%= javascript_include_tag :defaults %>
7
- <%= csrf_meta_tag %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,49 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require "active_model/railtie"
4
- require "active_record/railtie"
5
- require "action_controller/railtie"
6
- require "action_view/railtie"
7
- require "action_mailer/railtie"
8
-
9
- Bundler.require
10
- require "apartment"
11
-
12
- module Dummy
13
- class Application < Rails::Application
14
- # Settings in config/environments/* take precedence over those specified here.
15
- # Application configuration should go into files in config/initializers
16
- # -- all .rb files in that directory are automatically loaded.
17
- require 'apartment/elevators/subdomain'
18
- require 'apartment/elevators/domain'
19
-
20
- config.middleware.use Apartment::Elevators::Subdomain
21
-
22
- # Custom directories with classes and modules you want to be autoloadable.
23
- config.autoload_paths += %W(#{config.root}/lib)
24
-
25
- # Only load the plugins named here, in the order given (default is alphabetical).
26
- # :all can be used as a placeholder for all plugins not explicitly named.
27
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
28
-
29
- # Activate observers that should always be running.
30
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
31
-
32
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
33
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
34
- # config.time_zone = 'Central Time (US & Canada)'
35
-
36
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
37
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
38
- # config.i18n.default_locale = :de
39
-
40
- # JavaScript files you want as :defaults (application.js is always included).
41
- # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
42
-
43
- # Configure the default encoding used in templates for Ruby 1.9.
44
- config.encoding = "utf-8"
45
-
46
- # Configure sensitive parameters which will be filtered from the log file.
47
- config.filter_parameters += [:password]
48
- end
49
- end
@@ -1,11 +0,0 @@
1
- require 'rubygems'
2
-
3
- gemfile = File.expand_path('../../../../Gemfile', __FILE__)
4
-
5
- if File.exist?(gemfile)
6
- ENV['BUNDLE_GEMFILE'] = gemfile
7
- require 'bundler'
8
- Bundler.setup
9
- end
10
-
11
- $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,44 +0,0 @@
1
- # Warning: The database defined as "test" will be erased and
2
- # re-generated from your development database when you run "rake".
3
- # Do not set this db to the same as development or production.
4
- <% if defined?(JRUBY_VERSION) %>
5
- test:
6
- adapter: postgresql
7
- database: apartment_postgresql_test
8
- username: postgres
9
- min_messages: WARNING
10
- driver: org.postgresql.Driver
11
- url: jdbc:postgresql://localhost:5432/apartment_postgresql_test
12
- timeout: 5000
13
- pool: 5
14
-
15
- development:
16
- adapter: postgresql
17
- database: apartment_postgresql_development
18
- username: postgres
19
- min_messages: WARNING
20
- driver: org.postgresql.Driver
21
- url: jdbc:postgresql://localhost:5432/apartment_postgresql_development
22
- timeout: 5000
23
- pool: 5
24
- <% else %>
25
- test:
26
- adapter: postgresql
27
- database: apartment_postgresql_test
28
- username: postgres
29
- min_messages: WARNING
30
- pool: 5
31
- timeout: 5000
32
- host: localhost
33
- port: 5432
34
-
35
- development:
36
- adapter: postgresql
37
- database: apartment_postgresql_development
38
- username: postgres
39
- min_messages: WARNING
40
- pool: 5
41
- timeout: 5000
42
- host: localhost
43
- port: 5432
44
- <% end %>
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Dummy::Application.initialize!
@@ -1,28 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the webserver when you make code changes.
7
- config.cache_classes = false
8
-
9
- config.eager_load = false
10
-
11
- # Log error messages when you accidentally call methods on nil.
12
- config.whiny_nils = true
13
-
14
- # Show full error reports and disable caching
15
- config.consider_all_requests_local = true
16
- config.action_view.debug_rjs = true
17
- config.action_controller.perform_caching = false
18
-
19
- # Don't care if the mailer can't send
20
- config.action_mailer.raise_delivery_errors = false
21
-
22
- # Print deprecation notices to the Rails logger
23
- config.active_support.deprecation = :log
24
-
25
- # Only use best-standards-support built into browsers
26
- config.action_dispatch.best_standards_support = :builtin
27
- end
28
-