-
We're sorry, but something went wrong.
-
We've been notified about this issue and we'll take a look at it shortly.
-
-
-
diff --git a/spec/dummy/public/favicon.ico b/spec/dummy/public/favicon.ico
deleted file mode 100644
index e69de29b..00000000
diff --git a/spec/dummy/public/stylesheets/.gitkeep b/spec/dummy/public/stylesheets/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/spec/dummy/script/rails b/spec/dummy/script/rails
deleted file mode 100755
index 6c919a61..00000000
--- a/spec/dummy/script/rails
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-# This command will automatically be run when you run "rails" with Rails 3 gems installed
-# from the root of your application.
-
-APP_PATH = File.expand_path('../config/application', __dir__)
-require File.expand_path('../config/boot', __dir__)
-require 'rails/commands'
diff --git a/spec/dummy_engine/.gitignore b/spec/dummy_engine/.gitignore
deleted file mode 100644
index de5d954f..00000000
--- a/spec/dummy_engine/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.bundle/
-log/*.log
-pkg/
-test/dummy/db/*.sqlite3
-test/dummy/db/*.sqlite3-journal
-test/dummy/log/*.log
-test/dummy/tmp/
-test/dummy/.sass-cache
diff --git a/spec/dummy_engine/Gemfile b/spec/dummy_engine/Gemfile
deleted file mode 100644
index 53379fe9..00000000
--- a/spec/dummy_engine/Gemfile
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-source 'https://rubygems.org'
-
-# Declare your gem's dependencies in dummy_engine.gemspec.
-# Bundler will treat runtime dependencies like base dependencies, and
-# development dependencies will be added by default to the :development group.
-gemspec
-
-# Declare any dependencies that are still in development here instead of in
-# your gemspec. These might include edge Rails or gems from your path or
-# Git. Remember to move these dependencies to your gemspec before releasing
-# your gem to rubygems.org.
-
-# To use debugger
-# gem 'debugger'
-gem 'ros-apartment', require: 'apartment', path: '../../'
diff --git a/spec/dummy_engine/Rakefile b/spec/dummy_engine/Rakefile
deleted file mode 100644
index 72a61a74..00000000
--- a/spec/dummy_engine/Rakefile
+++ /dev/null
@@ -1,33 +0,0 @@
-# frozen_string_literal: true
-
-begin
- require 'bundler/setup'
-rescue LoadError
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
-end
-
-require 'rdoc/task'
-
-RDoc::Task.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'DummyEngine'
- rdoc.options << '--line-numbers'
- rdoc.rdoc_files.include('README.rdoc')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
-
-APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
-load 'rails/tasks/engine.rake'
-
-Bundler::GemHelper.install_tasks
-
-require 'rake/testtask'
-
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = false
-end
-
-task default: :test
diff --git a/spec/dummy_engine/bin/rails b/spec/dummy_engine/bin/rails
deleted file mode 100755
index 397f409e..00000000
--- a/spec/dummy_engine/bin/rails
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-# This command will automatically be run when you run "rails" with Rails 4 gems installed
-# from the root of your application.
-
-ENGINE_ROOT = File.expand_path('..', __dir__)
-ENGINE_PATH = File.expand_path('../lib/dummy_engine/engine', __dir__)
-
-# Set up gems listed in the Gemfile.
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
-require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
-
-require 'rails/all'
-require 'rails/engine/commands'
diff --git a/spec/dummy_engine/config/initializers/apartment.rb b/spec/dummy_engine/config/initializers/apartment.rb
deleted file mode 100644
index 419f12dd..00000000
--- a/spec/dummy_engine/config/initializers/apartment.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-# frozen_string_literal: true
-
-# Require whichever elevator you're using below here...
-#
-# require 'apartment/elevators/generic'
-# require 'apartment/elevators/domain'
-require 'apartment/elevators/subdomain'
-
-#
-# Apartment Configuration
-#
-Apartment.configure do |config|
- # These models will not be multi-tenanted,
- # but remain in the global (public) namespace
- #
- # An example might be a Customer or Tenant model that stores each tenant information
- # ex:
- #
- # config.excluded_models = %w{Tenant}
- #
- config.excluded_models = %w[]
-
- # use postgres schemas?
- config.use_schemas = true
-
- # use raw SQL dumps for creating postgres schemas? (only applies with use_schemas set to true)
- # config.use_sql = true
-
- # configure persistent schemas (E.g. hstore )
- # config.persistent_schemas = %w{ hstore }
-
- # add the Rails environment to database names?
- # config.prepend_environment = true
- # config.append_environment = true
-
- # supply list of database names for migrations to run on
- # config.tenant_names = lambda{ ToDo_Tenant_Or_User_Model.pluck :database }
-
- # Specify a connection other than ActiveRecord::Base for apartment to use
- # (only needed if your models are using a different connection)
- # config.connection_class = ActiveRecord::Base
-end
-
-##
-# Elevator Configuration
-
-# Rails.application.config.middleware.use Apartment::Elevators::Generic, lambda { |request|
-# # TODO: supply generic implementation
-# }
-
-# Rails.application.config.middleware.use Apartment::Elevators::Domain
-
-Rails.application.config.middleware.use Apartment::Elevators::Subdomain
diff --git a/spec/dummy_engine/lib/dummy_engine.rb b/spec/dummy_engine/lib/dummy_engine.rb
deleted file mode 100644
index 8f9c8111..00000000
--- a/spec/dummy_engine/lib/dummy_engine.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-require 'dummy_engine/engine'
-
-module DummyEngine
-end
diff --git a/spec/dummy_engine/lib/dummy_engine/engine.rb b/spec/dummy_engine/lib/dummy_engine/engine.rb
deleted file mode 100644
index d308ec0d..00000000
--- a/spec/dummy_engine/lib/dummy_engine/engine.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-module DummyEngine
- class Engine < ::Rails::Engine
- end
-end
diff --git a/spec/dummy_engine/lib/dummy_engine/version.rb b/spec/dummy_engine/lib/dummy_engine/version.rb
deleted file mode 100644
index 76d025df..00000000
--- a/spec/dummy_engine/lib/dummy_engine/version.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-module DummyEngine
- VERSION = '0.0.1'
-end
diff --git a/spec/dummy_engine/test/dummy/Rakefile b/spec/dummy_engine/test/dummy/Rakefile
deleted file mode 100644
index e51cf0e1..00000000
--- a/spec/dummy_engine/test/dummy/Rakefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-
-# Add your own tasks in files placed in lib/tasks ending in .rake,
-# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-
-require File.expand_path('config/application', __dir__)
-
-Rails.application.load_tasks
diff --git a/spec/dummy_engine/test/dummy/config.ru b/spec/dummy_engine/test/dummy/config.ru
deleted file mode 100644
index 667e328d..00000000
--- a/spec/dummy_engine/test/dummy/config.ru
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-# This file is used by Rack-based servers to start the application.
-
-require ::File.expand_path('config/environment', __dir__)
-run Rails.application
diff --git a/spec/dummy_engine/test/dummy/config/application.rb b/spec/dummy_engine/test/dummy/config/application.rb
deleted file mode 100644
index 0984f6ce..00000000
--- a/spec/dummy_engine/test/dummy/config/application.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-require File.expand_path('boot', __dir__)
-
-require 'rails/all'
-
-Bundler.require(*Rails.groups)
-require 'dummy_engine'
-
-module Dummy
- class Application < Rails::Application
- # Settings in config/environments/* take precedence over those specified here.
- # Application configuration should go into files in config/initializers
- # -- all .rb files in that directory are automatically loaded.
-
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
- # config.time_zone = 'Central Time (US & Canada)'
-
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
- # config.i18n.default_locale = :de
- end
-end
diff --git a/spec/dummy_engine/test/dummy/config/boot.rb b/spec/dummy_engine/test/dummy/config/boot.rb
deleted file mode 100644
index 6d2cba07..00000000
--- a/spec/dummy_engine/test/dummy/config/boot.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-# Set up gems listed in the Gemfile.
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
-
-require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
-$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
diff --git a/spec/dummy_engine/test/dummy/config/database.yml b/spec/dummy_engine/test/dummy/config/database.yml
deleted file mode 100644
index 1c1a37ca..00000000
--- a/spec/dummy_engine/test/dummy/config/database.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-# SQLite version 3.x
-# gem install sqlite3
-#
-# Ensure the SQLite 3 gem is defined in your Gemfile
-# gem 'sqlite3'
-#
-default: &default
- adapter: sqlite3
- pool: 5
- timeout: 5000
-
-development:
- <<: *default
- database: db/development.sqlite3
-
-# Warning: The database defined as "test" will be erased and
-# re-generated from your development database when you run "rake".
-# Do not set this db to the same as development or production.
-test:
- <<: *default
- database: db/test.sqlite3
-
-production:
- <<: *default
- database: db/production.sqlite3
diff --git a/spec/dummy_engine/test/dummy/config/environment.rb b/spec/dummy_engine/test/dummy/config/environment.rb
deleted file mode 100644
index 32d57aa4..00000000
--- a/spec/dummy_engine/test/dummy/config/environment.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-# Load the Rails application.
-require File.expand_path('application', __dir__)
-
-# Initialize the Rails application.
-Rails.application.initialize!
diff --git a/spec/dummy_engine/test/dummy/config/environments/development.rb b/spec/dummy_engine/test/dummy/config/environments/development.rb
deleted file mode 100644
index 8296624e..00000000
--- a/spec/dummy_engine/test/dummy/config/environments/development.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-Rails.application.configure do
- # Settings specified here will take precedence over those in config/application.rb.
-
- # In the development environment your application's code is reloaded on
- # every request. This slows down response time but is perfect for development
- # since you don't have to restart the web server when you make code changes.
- config.cache_classes = false
-
- # Do not eager load code on boot.
- config.eager_load = false
-
- # Show full error reports and disable caching.
- config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
-
- # Don't care if the mailer can't send.
- config.action_mailer.raise_delivery_errors = false
-
- # Print deprecation notices to the Rails logger.
- config.active_support.deprecation = :log
-
- # Raise an error on page load if there are pending migrations.
- config.active_record.migration_error = :page_load
-
- # Debug mode disables concatenation and preprocessing of assets.
- # This option may cause significant delays in view rendering with a large
- # number of complex assets.
- config.assets.debug = true
-
- # Adds additional error checking when serving assets at runtime.
- # Checks for improperly declared sprockets dependencies.
- # Raises helpful error messages.
- config.assets.raise_runtime_errors = true
-
- # Raises error for missing translations
- # config.action_view.raise_on_missing_translations = true
-end
diff --git a/spec/dummy_engine/test/dummy/config/environments/production.rb b/spec/dummy_engine/test/dummy/config/environments/production.rb
deleted file mode 100644
index 1bd152f1..00000000
--- a/spec/dummy_engine/test/dummy/config/environments/production.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-# frozen_string_literal: true
-
-Rails.application.configure do
- # Settings specified here will take precedence over those in config/application.rb.
-
- # Code is not reloaded between requests.
- config.cache_classes = true
-
- # Eager load code on boot. This eager loads most of Rails and
- # your application in memory, allowing both threaded web servers
- # and those relying on copy on write to perform better.
- # Rake tasks automatically ignore this option for performance.
- config.eager_load = true
-
- # Full error reports are disabled and caching is turned on.
- config.consider_all_requests_local = false
- config.action_controller.perform_caching = true
-
- # Enable Rack::Cache to put a simple HTTP cache in front of your application
- # Add `rack-cache` to your Gemfile before enabling this.
- # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
- # config.action_dispatch.rack_cache = true
-
- # Disable Rails's static asset server (Apache or nginx will already do this).
- config.serve_static_assets = false
-
- # Compress JavaScripts and CSS.
- config.assets.js_compressor = :uglifier
- # config.assets.css_compressor = :sass
-
- # Do not fallback to assets pipeline if a precompiled asset is missed.
- config.assets.compile = false
-
- # Generate digests for assets URLs.
- config.assets.digest = true
-
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
-
- # Specifies the header that your server uses for sending files.
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
-
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
- # config.force_ssl = true
-
- # Set to :debug to see everything in the log.
- config.log_level = :info
-
- # Prepend all log lines with the following tags.
- # config.log_tags = [ :subdomain, :uuid ]
-
- # Use a different logger for distributed setups.
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
-
- # Use a different cache store in production.
- # config.cache_store = :mem_cache_store
-
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
- # config.action_controller.asset_host = "http://assets.example.com"
-
- # Ignore bad email addresses and do not raise email delivery errors.
- # Set this to true and configure the email server for immediate delivery to raise delivery errors.
- # config.action_mailer.raise_delivery_errors = false
-
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
- # the I18n.default_locale when a translation cannot be found).
- config.i18n.fallbacks = true
-
- # Send deprecation notices to registered listeners.
- config.active_support.deprecation = :notify
-
- # Disable automatic flushing of the log to improve performance.
- # config.autoflush_log = false
-
- # Use default logging formatter so that PID and timestamp are not suppressed.
- config.log_formatter = ::Logger::Formatter.new
-
- # Do not dump schema after migrations.
- config.active_record.dump_schema_after_migration = false
-end
diff --git a/spec/dummy_engine/test/dummy/config/environments/test.rb b/spec/dummy_engine/test/dummy/config/environments/test.rb
deleted file mode 100644
index bd942389..00000000
--- a/spec/dummy_engine/test/dummy/config/environments/test.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: true
-
-Rails.application.configure do
- # Settings specified here will take precedence over those in config/application.rb.
-
- # The test environment is used exclusively to run your application's
- # test suite. You never need to work with it otherwise. Remember that
- # your test database is "scratch space" for the test suite and is wiped
- # and recreated between test runs. Don't rely on the data there!
- config.cache_classes = true
-
- # Do not eager load code on boot. This avoids loading your whole application
- # just for the purpose of running a single test. If you are using a tool that
- # preloads Rails for running tests, you may have to set it to true.
- config.eager_load = false
-
- # Configure static asset server for tests with Cache-Control for performance.
- config.serve_static_assets = true
- config.static_cache_control = 'public, max-age=3600'
-
- # Show full error reports and disable caching.
- config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
-
- # Raise exceptions instead of rendering exception templates.
- config.action_dispatch.show_exceptions = false
-
- # Disable request forgery protection in test environment.
- config.action_controller.allow_forgery_protection = false
-
- # Tell Action Mailer not to deliver emails to the real world.
- # The :test delivery method accumulates sent emails in the
- # ActionMailer::Base.deliveries array.
- config.action_mailer.delivery_method = :test
-
- # Print deprecation notices to the stderr.
- config.active_support.deprecation = :stderr
-
- # Raises error for missing translations
- # config.action_view.raise_on_missing_translations = true
-end
diff --git a/spec/dummy_engine/test/dummy/config/initializers/assets.rb b/spec/dummy_engine/test/dummy/config/initializers/assets.rb
deleted file mode 100644
index 761905a7..00000000
--- a/spec/dummy_engine/test/dummy/config/initializers/assets.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# frozen_string_literal: true
-
-# Be sure to restart your server when you modify this file.
-
-# Version of your assets, change this if you want to expire all your assets.
-Rails.application.config.assets.version = '1.0'
-
-# Precompile additional assets.
-# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
-# Rails.application.config.assets.precompile += %w( search.js )
diff --git a/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb b/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb
deleted file mode 100644
index d0f0d3b5..00000000
--- a/spec/dummy_engine/test/dummy/config/initializers/backtrace_silencers.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-# frozen_string_literal: true
-# Be sure to restart your server when you modify this file.
-
-# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
-# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
-
-# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
-# Rails.backtrace_cleaner.remove_silencers!
diff --git a/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb b/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb
deleted file mode 100644
index 0a23b25e..00000000
--- a/spec/dummy_engine/test/dummy/config/initializers/cookies_serializer.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-# Be sure to restart your server when you modify this file.
-
-Rails.application.config.action_dispatch.cookies_serializer = :json
diff --git a/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb b/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb
deleted file mode 100644
index 7a4f47b4..00000000
--- a/spec/dummy_engine/test/dummy/config/initializers/filter_parameter_logging.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-
-# Be sure to restart your server when you modify this file.
-
-# Configure sensitive parameters which will be filtered from the log file.
-Rails.application.config.filter_parameters += [:password]
diff --git a/spec/dummy_engine/test/dummy/config/initializers/inflections.rb b/spec/dummy_engine/test/dummy/config/initializers/inflections.rb
deleted file mode 100644
index aa7435fb..00000000
--- a/spec/dummy_engine/test/dummy/config/initializers/inflections.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-# Be sure to restart your server when you modify this file.
-
-# Add new inflection rules using the following format. Inflections
-# are locale specific, and you may define rules for as many different
-# locales as you wish. All of these examples are active by default:
-# ActiveSupport::Inflector.inflections(:en) do |inflect|
-# inflect.plural /^(ox)$/i, '\1en'
-# inflect.singular /^(ox)en/i, '\1'
-# inflect.irregular 'person', 'people'
-# inflect.uncountable %w( fish sheep )
-# end
-
-# These inflection rules are supported but not enabled by default:
-# ActiveSupport::Inflector.inflections(:en) do |inflect|
-# inflect.acronym 'RESTful'
-# end
diff --git a/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb b/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb
deleted file mode 100644
index 6e1d16f0..00000000
--- a/spec/dummy_engine/test/dummy/config/initializers/mime_types.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-# Be sure to restart your server when you modify this file.
-
-# Add new mime types for use in respond_to blocks:
-# Mime::Type.register "text/richtext", :rtf
diff --git a/spec/dummy_engine/test/dummy/config/initializers/session_store.rb b/spec/dummy_engine/test/dummy/config/initializers/session_store.rb
deleted file mode 100644
index 969d977f..00000000
--- a/spec/dummy_engine/test/dummy/config/initializers/session_store.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-# Be sure to restart your server when you modify this file.
-
-Rails.application.config.session_store :cookie_store, key: '_dummy_session'
diff --git a/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb b/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb
deleted file mode 100644
index 246168a4..00000000
--- a/spec/dummy_engine/test/dummy/config/initializers/wrap_parameters.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-# Be sure to restart your server when you modify this file.
-
-# This file contains settings for ActionController::ParamsWrapper which
-# is enabled by default.
-
-# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
-ActiveSupport.on_load(:action_controller) do
- wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
-end
-
-# To enable root element in JSON for ActiveRecord objects.
-# ActiveSupport.on_load(:active_record) do
-# self.include_root_in_json = true
-# end
diff --git a/spec/dummy_engine/test/dummy/config/locales/en.yml b/spec/dummy_engine/test/dummy/config/locales/en.yml
deleted file mode 100644
index 06539571..00000000
--- a/spec/dummy_engine/test/dummy/config/locales/en.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-# Files in the config/locales directory are used for internationalization
-# and are automatically loaded by Rails. If you want to use locales other
-# than English, add the necessary files in this directory.
-#
-# To use the locales, use `I18n.t`:
-#
-# I18n.t 'hello'
-#
-# In views, this is aliased to just `t`:
-#
-# <%= t('hello') %>
-#
-# To use a different locale, set it with `I18n.locale`:
-#
-# I18n.locale = :es
-#
-# This would use the information in config/locales/es.yml.
-#
-# To learn more, please read the Rails Internationalization guide
-# available at http://guides.rubyonrails.org/i18n.html.
-
-en:
- hello: "Hello world"
diff --git a/spec/dummy_engine/test/dummy/config/routes.rb b/spec/dummy_engine/test/dummy/config/routes.rb
deleted file mode 100644
index 189947fc..00000000
--- a/spec/dummy_engine/test/dummy/config/routes.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-# frozen_string_literal: true
-
-Rails.application.routes.draw do
- # The priority is based upon order of creation: first created -> highest priority.
- # See how all your routes lay out with "rake routes".
-
- # You can have the root of your site routed with "root"
- # root 'welcome#index'
-
- # Example of regular route:
- # get 'products/:id' => 'catalog#view'
-
- # Example of named route that can be invoked with purchase_url(id: product.id)
- # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
-
- # Example resource route (maps HTTP verbs to controller actions automatically):
- # resources :products
-
- # Example resource route with options:
- # resources :products do
- # member do
- # get 'short'
- # post 'toggle'
- # end
- #
- # collection do
- # get 'sold'
- # end
- # end
-
- # Example resource route with sub-resources:
- # resources :products do
- # resources :comments, :sales
- # resource :seller
- # end
-
- # Example resource route with more complex sub-resources:
- # resources :products do
- # resources :comments
- # resources :sales do
- # get 'recent', on: :collection
- # end
- # end
-
- # Example resource route with concerns:
- # concern :toggleable do
- # post 'toggle'
- # end
- # resources :posts, concerns: :toggleable
- # resources :photos, concerns: :toggleable
-
- # Example resource route within a namespace:
- # namespace :admin do
- # # Directs /admin/products/* to Admin::ProductsController
- # # (app/controllers/admin/products_controller.rb)
- # resources :products
- # end
-end
diff --git a/spec/dummy_engine/test/dummy/config/secrets.yml b/spec/dummy_engine/test/dummy/config/secrets.yml
deleted file mode 100644
index ee200137..00000000
--- a/spec/dummy_engine/test/dummy/config/secrets.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Your secret key is used for verifying the integrity of signed cookies.
-# If you change this key, all old signed cookies will become invalid!
-
-# Make sure the secret is at least 30 characters and all random,
-# no regular words or you'll be exposed to dictionary attacks.
-# You can use `rake secret` to generate a secure secret key.
-
-# Make sure the secrets in this file are kept private
-# if you're sharing your code publicly.
-
-development:
- secret_key_base: bb62b819b585a74e69c797f9d03d5a004d8fe82a8e7a7da6fa2f7923030713b7b087c12cc7a918e71073c38afb343f7223d22ba3f1b223b7e76dbf8d5b65fa2c
-
-test:
- secret_key_base: 67945d3b189c71dffef98de2bb7c14d6fb059679c115ca3cddf65c88babe130afe4d583560d0e308b017dd76ce305bef4159d876de9fd893952d9cbf269c8476
-
-# Do not keep production secrets in the repository,
-# instead read values from the environment.
-production:
- secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
diff --git a/spec/examples/connection_adapter_examples.rb b/spec/examples/connection_adapter_examples.rb
deleted file mode 100644
index 973ed1fa..00000000
--- a/spec/examples/connection_adapter_examples.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-shared_examples_for 'a connection based apartment adapter' do
- include Apartment::Spec::AdapterRequirements
-
- let(:default_tenant) { subject.switch { ActiveRecord::Base.connection.current_database } }
-
- describe '#init' do
- after do
- # Apartment::Tenant.init creates per model connection.
- # Remove the connection after testing not to unintentionally keep the connection across tests.
- Apartment.excluded_models.each do |excluded_model|
- excluded_model.constantize.remove_connection
- end
- end
-
- it 'should process model exclusions' do
- Apartment.configure do |config|
- config.excluded_models = ['Company']
- end
- Apartment::Tenant.init
-
- expect(Company.connection.object_id).not_to eq(ActiveRecord::Base.connection.object_id)
- end
- end
-
- describe '#drop' do
- it 'should raise an error for unknown database' do
- expect do
- subject.drop 'unknown_database'
- end.to raise_error(Apartment::TenantNotFound)
- end
- end
-
- describe '#switch!' do
- it 'should raise an error if database is invalid' do
- expect do
- subject.switch! 'unknown_database'
- end.to raise_error(Apartment::TenantNotFound)
- end
- end
-end
diff --git a/spec/examples/generic_adapter_custom_configuration_example.rb b/spec/examples/generic_adapter_custom_configuration_example.rb
deleted file mode 100644
index 2ad7ee20..00000000
--- a/spec/examples/generic_adapter_custom_configuration_example.rb
+++ /dev/null
@@ -1,97 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-shared_examples_for 'a generic apartment adapter able to handle custom configuration' do
- let(:custom_tenant_name) { 'test_tenantwwww' }
- let(:db) { |example| example.metadata[:database] }
- let(:custom_tenant_names) do
- {
- custom_tenant_name => custom_db_conf
- }
- end
-
- before do
- Apartment.tenant_names = custom_tenant_names
- Apartment.with_multi_server_setup = true
- end
-
- after do
- Apartment.with_multi_server_setup = false
- end
-
- context 'database key taken from specific config' do
- let(:expected_args) { custom_db_conf }
-
- describe '#create' do
- it 'should establish_connection with the separate connection with expected args' do
- expect(Apartment::Adapters::AbstractAdapter::SeparateDbConnectionHandler).to(
- receive(:establish_connection).with(expected_args).and_call_original
- )
-
- # because we don't have another server to connect to it errors
- # what matters is establish_connection receives proper args
- expect { subject.create(custom_tenant_name) }.to raise_error(Apartment::TenantExists)
- end
- end
-
- describe '#drop' do
- it 'should establish_connection with the separate connection with expected args' do
- expect(Apartment::Adapters::AbstractAdapter::SeparateDbConnectionHandler).to(
- receive(:establish_connection).with(expected_args).and_call_original
- )
-
- # because we dont have another server to connect to it errors
- # what matters is establish_connection receives proper args
- expect { subject.drop(custom_tenant_name) }.to raise_error(Apartment::TenantNotFound)
- end
- end
- end
-
- context 'database key from tenant name' do
- let(:expected_args) do
- custom_db_conf.tap { |args| args.delete(:database) }
- end
-
- describe '#switch!' do
- it 'should connect to new db' do
- expect(Apartment).to receive(:establish_connection) do |args|
- db_name = args.delete(:database)
-
- expect(args).to eq expected_args
- expect(db_name).to match custom_tenant_name
-
- # we only need to check args, then we short circuit
- # in order to avoid the mess due to the `establish_connection` override
- raise ActiveRecord::ActiveRecordError
- end
-
- expect { subject.switch!(custom_tenant_name) }.to raise_error(Apartment::TenantNotFound)
- end
- end
- end
-
- def specific_connection
- {
- postgresql: {
- adapter: 'postgresql',
- database: 'override_database',
- password: 'override_password',
- username: 'overridepostgres'
- },
- mysql: {
- adapter: 'mysql2',
- database: 'override_database',
- username: 'root'
- },
- sqlite: {
- adapter: 'sqlite3',
- database: 'override_database'
- }
- }
- end
-
- def custom_db_conf
- specific_connection[db.to_sym].with_indifferent_access
- end
-end
diff --git a/spec/examples/generic_adapter_examples.rb b/spec/examples/generic_adapter_examples.rb
deleted file mode 100644
index 7999a6d2..00000000
--- a/spec/examples/generic_adapter_examples.rb
+++ /dev/null
@@ -1,166 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-shared_examples_for 'a generic apartment adapter' do
- include Apartment::Spec::AdapterRequirements
-
- before do
- Apartment.prepend_environment = false
- Apartment.append_environment = false
- Apartment.tenant_presence_check = true
- end
-
- describe '#init' do
- it 'should not connect if env var is set' do
- ENV['APARTMENT_DISABLE_INIT'] = 'true'
- begin
- ActiveRecord::Base.connection_pool.disconnect!
-
- Apartment::Railtie.config.to_prepare_blocks.map(&:call)
-
- num_available_connections = Apartment.connection_class.connection_pool
- .instance_variable_get(:@available)
- .instance_variable_get(:@queue)
- .size
-
- expect(num_available_connections).to eq(0)
- ensure
- ENV.delete('APARTMENT_DISABLE_INIT')
- end
- end
- end
-
- #
- # Creates happen already in our before_filter
- #
- describe '#create' do
- it 'should create the new databases' do
- expect(tenant_names).to include(db1)
- expect(tenant_names).to include(db2)
- end
-
- it 'should load schema.rb to new schema' do
- subject.switch(db1) do
- expect(connection.tables).to include('users')
- end
- end
-
- it 'should yield to block if passed and reset' do
- subject.drop(db2) # so we don't get errors on creation
-
- @count = 0 # set our variable so its visible in and outside of blocks
-
- subject.create(db2) do
- @count = User.count
- expect(subject.current).to eq(db2)
- User.create
- end
-
- expect(subject.current).not_to eq(db2)
-
- subject.switch(db2) { expect(User.count).to eq(@count + 1) }
- end
-
- it 'should raise error when the schema.rb is missing unless Apartment.use_sql is set to true' do
- next if Apartment.use_sql
-
- subject.drop(db1)
- begin
- Dir.mktmpdir do |tmpdir|
- Apartment.database_schema_file = "#{tmpdir}/schema.rb"
- expect do
- subject.create(db1)
- end.to raise_error(Apartment::FileNotFound)
- end
- ensure
- Apartment.remove_instance_variable(:@database_schema_file)
- end
- end
- end
-
- describe '#drop' do
- it 'should remove the db' do
- subject.drop db1
- expect(tenant_names).not_to include(db1)
- end
- end
-
- describe '#switch!' do
- it 'should connect to new db' do
- subject.switch!(db1)
- expect(subject.current).to eq(db1)
- end
-
- it 'should reset connection if database is nil' do
- subject.switch!
- expect(subject.current).to eq(default_tenant)
- end
-
- it 'should raise an error if database is invalid' do
- expect do
- subject.switch! 'unknown_database'
- end.to raise_error(Apartment::TenantNotFound)
- end
- end
-
- describe '#switch' do
- it 'connects and resets the tenant' do
- subject.switch(db1) do
- expect(subject.current).to eq(db1)
- end
- expect(subject.current).to eq(default_tenant)
- end
-
- # We're often finding when using Apartment in tests, the `current` (ie the previously connect to db)
- # gets dropped, but switch will try to return to that db in a test. We should just reset if it doesn't exist
- it 'should not throw exception if current is no longer accessible' do
- subject.switch!(db2)
-
- expect do
- subject.switch(db1) { subject.drop(db2) }
- end.not_to raise_error
- end
- end
-
- describe '#reset' do
- it 'should reset connection' do
- subject.switch!(db1)
- subject.reset
- expect(subject.current).to eq(default_tenant)
- end
- end
-
- describe '#current' do
- it 'should return the current db name' do
- subject.switch!(db1)
- expect(subject.current).to eq(db1)
- end
- end
-
- describe '#each' do
- it 'iterates over each tenant by default' do
- result = []
- Apartment.tenant_names = [db2, db1]
-
- subject.each do |tenant|
- result << tenant
- expect(subject.current).to eq(tenant)
- end
-
- expect(result).to eq([db2, db1])
- end
-
- it 'iterates over the given tenants' do
- result = []
- Apartment.tenant_names = [db2]
-
- subject.each([db2]) do |tenant|
- result << tenant
- expect(subject.current).to eq(tenant)
- end
-
- expect(result).to eq([db2])
- end
- end
-end
diff --git a/spec/examples/generic_adapters_callbacks_examples.rb b/spec/examples/generic_adapters_callbacks_examples.rb
deleted file mode 100644
index 3184a4a1..00000000
--- a/spec/examples/generic_adapters_callbacks_examples.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-shared_examples_for 'a generic apartment adapter callbacks' do
- # rubocop:disable Lint/ConstantDefinitionInBlock
- class MyProc
- def self.call(tenant_name); end
- end
- # rubocop:enable Lint/ConstantDefinitionInBlock
-
- include Apartment::Spec::AdapterRequirements
-
- before do
- Apartment.prepend_environment = false
- Apartment.append_environment = false
- end
-
- describe '#switch!' do
- before do
- Apartment::Adapters::AbstractAdapter.set_callback :switch, :before do
- MyProc.call(Apartment::Tenant.current)
- end
-
- Apartment::Adapters::AbstractAdapter.set_callback :switch, :after do
- MyProc.call(Apartment::Tenant.current)
- end
-
- allow(MyProc).to receive(:call)
- end
-
- # NOTE: Part of the test setup creates and switches tenants, so we need
- # to reset the callbacks to ensure that each test run has the correct
- # counts
- after do
- Apartment::Adapters::AbstractAdapter.reset_callbacks :switch
- end
-
- context 'when tenant is nil' do
- before do
- Apartment::Tenant.switch!(nil)
- end
-
- it 'runs both before and after callbacks' do
- expect(MyProc).to have_received(:call).twice
- end
- end
-
- context 'when tenant is not nil' do
- before do
- Apartment::Tenant.switch!(db1)
- end
-
- it 'runs both before and after callbacks' do
- expect(MyProc).to have_received(:call).twice
- end
- end
- end
-end
diff --git a/spec/examples/schema_adapter_examples.rb b/spec/examples/schema_adapter_examples.rb
deleted file mode 100644
index 452eb6f2..00000000
--- a/spec/examples/schema_adapter_examples.rb
+++ /dev/null
@@ -1,316 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-shared_examples_for 'a schema based apartment adapter' do
- include Apartment::Spec::AdapterRequirements
-
- let(:schema1) { db1 }
- let(:schema2) { db2 }
- let(:public_schema) { default_tenant }
-
- describe '#init' do
- before do
- Apartment.configure do |config|
- config.excluded_models = ['Company']
- end
- end
-
- after do
- # Apartment::Tenant.init creates per model connection.
- # Remove the connection after testing not to unintentionally keep the connection across tests.
- Apartment.excluded_models.each do |excluded_model|
- excluded_model.constantize.remove_connection
- end
- end
-
- it 'should process model exclusions' do
- Apartment::Tenant.init
-
- expect(Company.table_name).to eq('public.companies')
- expect(Company.sequence_name).to eq('public.companies_id_seq')
- expect(User.table_name).to eq('users')
- expect(User.sequence_name).to eq('users_id_seq')
- end
-
- context 'with a default_tenant', default_tenant: true do
- it 'should set the proper table_name on excluded_models' do
- Apartment::Tenant.init
-
- expect(Company.table_name).to eq("#{default_tenant}.companies")
- expect(Company.sequence_name).to eq("#{default_tenant}.companies_id_seq")
- expect(User.table_name).to eq('users')
- expect(User.sequence_name).to eq('users_id_seq')
- end
-
- it 'sets the search_path correctly' do
- Apartment::Tenant.init
-
- expect(User.connection.schema_search_path).to match(/|#{default_tenant}|/)
- end
- end
-
- context 'persistent_schemas', persistent_schemas: true do
- it 'sets the persistent schemas in the schema_search_path' do
- Apartment::Tenant.init
- expect(connection.schema_search_path).to end_with persistent_schemas.map { |schema| %("#{schema}") }.join(', ')
- end
- end
- end
-
- #
- # Creates happen already in our before_filter
- #
- describe '#create' do
- it 'should load schema.rb to new schema' do
- connection.schema_search_path = schema1
- expect(connection.tables).to include('users')
- end
-
- it 'should yield to block if passed and reset' do
- subject.drop(schema2) # so we don't get errors on creation
-
- @count = 0 # set our variable so its visible in and outside of blocks
-
- subject.create(schema2) do
- @count = User.count
- expect(connection.schema_search_path).to start_with %("#{schema2}")
- User.create
- end
-
- expect(connection.schema_search_path).not_to start_with %("#{schema2}")
-
- subject.switch(schema2) { expect(User.count).to eq(@count + 1) }
- end
-
- context 'numeric database names' do
- let(:db) { 1234 }
- it 'should allow them' do
- expect do
- subject.create(db)
- end.not_to raise_error
- expect(tenant_names).to include(db.to_s)
- end
-
- after { subject.drop(db) }
- end
-
- context 'with a default_tenant', default_tenant: true do
- let(:from_default_tenant) { 'new_from_custom_default_tenant' }
-
- before do
- subject.create(from_default_tenant)
- end
-
- after do
- subject.drop(from_default_tenant)
- end
-
- it 'should correctly create the new schema' do
- expect(tenant_names).to include(from_default_tenant)
- end
-
- it 'should load schema.rb to new schema' do
- connection.schema_search_path = from_default_tenant
- expect(connection.tables).to include('users')
- end
- end
- end
-
- describe '#drop' do
- it 'should raise an error for unknown database' do
- expect do
- subject.drop 'unknown_database'
- end.to raise_error(Apartment::TenantNotFound)
- end
-
- context 'numeric database names' do
- let(:db) { 1234 }
-
- it 'should be able to drop them' do
- subject.create(db)
- expect do
- subject.drop(db)
- end.not_to raise_error
- expect(tenant_names).not_to include(db.to_s)
- end
-
- after do
- subject.drop(db)
- rescue StandardError => _e
- nil
- end
- end
- end
-
- describe '#switch' do
- before do
- Apartment.configure do |config|
- config.excluded_models = ['Company']
- end
- end
-
- it 'connects and resets' do
- subject.switch(schema1) do
- # Ensure sequence is not cached
- Company.reset_sequence_name
- User.reset_sequence_name
-
- expect(connection.schema_search_path).to start_with %("#{schema1}")
- expect(User.sequence_name).to eq "#{User.table_name}_id_seq"
- expect(Company.sequence_name).to eq "#{public_schema}.#{Company.table_name}_id_seq"
- end
-
- expect(connection.schema_search_path).to start_with %("#{public_schema}")
- expect(User.sequence_name).to eq "#{User.table_name}_id_seq"
- expect(Company.sequence_name).to eq "#{public_schema}.#{Company.table_name}_id_seq"
- end
-
- describe 'multiple schemas' do
- it 'allows a list of schemas' do
- subject.switch([schema1, schema2]) do
- expect(connection.schema_search_path).to include %("#{schema1}")
- expect(connection.schema_search_path).to include %("#{schema2}")
- end
- end
-
- it 'connects and resets' do
- subject.switch([schema1, schema2]) do
- # Ensure sequence is not cached
- Company.reset_sequence_name
- User.reset_sequence_name
-
- expect(connection.schema_search_path).to start_with %("#{schema1}")
- expect(User.sequence_name).to eq "#{User.table_name}_id_seq"
- expect(Company.sequence_name).to eq "#{public_schema}.#{Company.table_name}_id_seq"
- end
-
- expect(connection.schema_search_path).to start_with %("#{public_schema}")
- expect(User.sequence_name).to eq "#{User.table_name}_id_seq"
- expect(Company.sequence_name).to eq "#{public_schema}.#{Company.table_name}_id_seq"
- end
- end
- end
-
- describe '#reset' do
- it 'should reset connection' do
- subject.switch!(schema1)
- subject.reset
- expect(connection.schema_search_path).to start_with %("#{public_schema}")
- end
-
- context 'with default_tenant', default_tenant: true do
- it 'should reset to the default schema' do
- subject.switch!(schema1)
- subject.reset
- expect(connection.schema_search_path).to start_with %("#{default_tenant}")
- end
- end
-
- context 'persistent_schemas', persistent_schemas: true do
- before do
- subject.switch!(schema1)
- subject.reset
- end
-
- it 'maintains the persistent schemas in the schema_search_path' do
- expect(connection.schema_search_path).to end_with persistent_schemas.map { |schema| %("#{schema}") }.join(', ')
- end
-
- context 'with default_tenant', default_tenant: true do
- it 'prioritizes the switched schema to front of schema_search_path' do
- subject.reset # need to re-call this as the default_tenant wasn't set at the time that the above reset ran
- expect(connection.schema_search_path).to start_with %("#{default_tenant}")
- end
- end
- end
- end
-
- describe '#switch!' do
- let(:tenant_presence_check) { true }
-
- before { Apartment.tenant_presence_check = tenant_presence_check }
-
- it 'should connect to new schema' do
- subject.switch!(schema1)
- expect(connection.schema_search_path).to start_with %("#{schema1}")
- end
-
- it 'should reset connection if database is nil' do
- subject.switch!
- expect(connection.schema_search_path).to eq(%("#{public_schema}"))
- end
-
- context 'when configuration checks for tenant presence before switching' do
- it 'should raise an error if schema is invalid' do
- expect do
- subject.switch! 'unknown_schema'
- end.to raise_error(Apartment::TenantNotFound)
- end
- end
-
- context 'when configuration skips tenant presence check before switching' do
- let(:tenant_presence_check) { false }
-
- it 'should not raise any errors' do
- expect do
- subject.switch! 'unknown_schema'
- end.not_to raise_error
- end
- end
-
- context 'numeric databases' do
- let(:db) { 1234 }
-
- it 'should connect to them' do
- subject.create(db)
- expect do
- subject.switch!(db)
- end.not_to raise_error
-
- expect(connection.schema_search_path).to start_with %("#{db}")
- end
-
- after { subject.drop(db) }
- end
-
- describe 'with default_tenant specified', default_tenant: true do
- before do
- subject.switch!(schema1)
- end
-
- it 'should switch out the default schema rather than public' do
- expect(connection.schema_search_path).not_to include default_tenant
- end
-
- it 'should still switch to the switched schema' do
- expect(connection.schema_search_path).to start_with %("#{schema1}")
- end
- end
-
- context 'persistent_schemas', persistent_schemas: true do
- before { subject.switch!(schema1) }
-
- it 'maintains the persistent schemas in the schema_search_path' do
- expect(connection.schema_search_path).to end_with persistent_schemas.map { |schema| %("#{schema}") }.join(', ')
- end
-
- it 'prioritizes the switched schema to front of schema_search_path' do
- expect(connection.schema_search_path).to start_with %("#{schema1}")
- end
- end
- end
-
- describe '#current' do
- it 'should return the current schema name' do
- subject.switch!(schema1)
- expect(subject.current).to eq(schema1)
- end
-
- context 'persistent_schemas', persistent_schemas: true do
- it 'should exlude persistent_schemas' do
- subject.switch!(schema1)
- expect(subject.current).to eq(schema1)
- end
- end
- end
-end
diff --git a/spec/integration/apartment_rake_integration_spec.rb b/spec/integration/apartment_rake_integration_spec.rb
deleted file mode 100644
index 530f8146..00000000
--- a/spec/integration/apartment_rake_integration_spec.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require 'rake'
-
-describe 'apartment rake tasks', database: :postgresql do
- before do
- @rake = Rake::Application.new
- Rake.application = @rake
- Dummy::Application.load_tasks
-
- # rails tasks running F up the schema...
- Rake::Task.define_task('db:migrate')
- Rake::Task.define_task('db:seed')
- Rake::Task.define_task('db:rollback')
- Rake::Task.define_task('db:migrate:up')
- Rake::Task.define_task('db:migrate:down')
- Rake::Task.define_task('db:migrate:redo')
-
- Apartment.configure do |config|
- config.use_schemas = true
- config.excluded_models = ['Company']
- config.tenant_names = -> { Company.pluck(:database) }
- end
- Apartment::Tenant.reload!(config)
-
- # fix up table name of shared/excluded models
- Company.table_name = 'public.companies'
- end
-
- after { Rake.application = nil }
-
- context 'with x number of databases' do
- let(:x) { rand(1..5) } # random number of dbs to create
- let(:db_names) { Array.new(x).map { Apartment::Test.next_db } }
- let!(:company_count) { db_names.length }
-
- before do
- db_names.collect do |db_name|
- Apartment::Tenant.create(db_name)
- Company.create database: db_name
- end
- end
-
- after do
- db_names.each { |db| Apartment::Tenant.drop(db) }
- Company.delete_all
- end
-
- context 'with ActiveRecord above or equal to 5.2.0' do
- let(:migration_context_double) { double(:migration_context) }
-
- describe '#migrate' do
- it 'should migrate all databases' do
- if ActiveRecord.version >= Gem::Version.new('7.2.0')
- allow(ActiveRecord::Base.connection_pool)
- else
- allow(ActiveRecord::Base.connection)
- end.to receive(:migration_context) { migration_context_double }
- expect(migration_context_double).to receive(:migrate).exactly(company_count).times
-
- @rake['apartment:migrate'].invoke
- end
- end
-
- describe '#rollback' do
- it 'should rollback all dbs' do
- if ActiveRecord.version >= Gem::Version.new('7.2.0')
- allow(ActiveRecord::Base.connection_pool)
- else
- allow(ActiveRecord::Base.connection)
- end.to receive(:migration_context) { migration_context_double }
- expect(migration_context_double).to receive(:rollback).exactly(company_count).times
-
- @rake['apartment:rollback'].invoke
- end
- end
- end
-
- describe 'apartment:seed' do
- it 'should seed all databases' do
- expect(Apartment::Tenant).to receive(:seed).exactly(company_count).times
-
- @rake['apartment:seed'].invoke
- end
- end
- end
-end
diff --git a/spec/integration/connection_handling_spec.rb b/spec/integration/connection_handling_spec.rb
deleted file mode 100644
index 5b3e10fb..00000000
--- a/spec/integration/connection_handling_spec.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe 'connection handling monkey patch' do
- let(:db_name) { db1 }
-
- before do
- Apartment.configure do |config|
- config.excluded_models = ['Company']
- config.tenant_names = -> { Company.pluck(:database) }
- config.use_schemas = true
- end
-
- Apartment::Tenant.reload!(config)
-
- Apartment::Tenant.create(db_name)
- Company.create database: db_name
- Apartment::Tenant.switch! db_name
- User.create! name: db_name
- end
-
- after do
- Apartment::Tenant.drop(db_name)
- Apartment::Tenant.reset
- Company.delete_all
- end
-
- context 'when ActiveRecord >= 6.0', if: ActiveRecord::VERSION::MAJOR >= 6 do
- let(:role) do
- # Choose the role depending on the ActiveRecord version.
- case ActiveRecord::VERSION::MAJOR
- when 6 then ActiveRecord::Base.writing_role # deprecated in Rails 7
- else ActiveRecord.writing_role
- end
- end
-
- it 'is monkey patched' do
- expect(ActiveRecord::ConnectionHandling.instance_methods).to include(:connected_to_with_tenant)
- end
-
- it 'switches to the previous set tenant' do
- Apartment::Tenant.switch! db_name
- ActiveRecord::Base.connected_to(role: role) do
- expect(Apartment::Tenant.current).to eq db_name
- expect(User.find_by(name: db_name).name).to eq(db_name)
- end
- end
- end
-end
diff --git a/spec/integration/query_caching_spec.rb b/spec/integration/query_caching_spec.rb
deleted file mode 100644
index e7a4ebdf..00000000
--- a/spec/integration/query_caching_spec.rb
+++ /dev/null
@@ -1,81 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe 'query caching' do
- describe 'when use_schemas = true' do
- let(:db_names) { [db1, db2] }
-
- before do
- Apartment.configure do |config|
- config.excluded_models = ['Company']
- config.tenant_names = -> { Company.pluck(:database) }
- config.use_schemas = true
- end
-
- Apartment::Tenant.reload!(config)
-
- db_names.each do |db_name|
- Apartment::Tenant.create(db_name)
- Company.create database: db_name
- end
- end
-
- after do
- db_names.each { |db| Apartment::Tenant.drop(db) }
- Apartment::Tenant.reset
- Company.delete_all
- end
-
- it 'clears the ActiveRecord::QueryCache after switching databases' do
- db_names.each do |db_name|
- Apartment::Tenant.switch! db_name
- User.create! name: db_name
- end
-
- ActiveRecord::Base.connection.enable_query_cache!
-
- Apartment::Tenant.switch! db_names.first
- expect(User.find_by(name: db_names.first).name).to eq(db_names.first)
-
- Apartment::Tenant.switch! db_names.last
- expect(User.find_by(name: db_names.first)).to be_nil
- end
- end
-
- describe 'when use_schemas = false' do
- let(:db_name) { db1 }
-
- before do
- Apartment.configure do |config|
- config.excluded_models = ['Company']
- config.tenant_names = -> { Company.pluck(:database) }
- config.use_schemas = false
- end
-
- Apartment::Tenant.reload!(config)
-
- Apartment::Tenant.create(db_name)
- Company.create database: db_name
- end
-
- after do
- Apartment::Tenant.reset
-
- Apartment::Tenant.drop(db_name)
- Company.delete_all
- end
-
- it 'configuration value is kept after switching databases' do
- ActiveRecord::Base.connection.enable_query_cache!
-
- Apartment::Tenant.switch! db_name
- expect(Apartment.connection.query_cache_enabled).to be true
-
- ActiveRecord::Base.connection.disable_query_cache!
-
- Apartment::Tenant.switch! db_name
- expect(Apartment.connection.query_cache_enabled).to be false
- end
- end
-end
diff --git a/spec/integration/use_within_an_engine_spec.rb b/spec/integration/use_within_an_engine_spec.rb
deleted file mode 100644
index f3269ba4..00000000
--- a/spec/integration/use_within_an_engine_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-
-describe 'using apartment within an engine' do
- before do
- engine_path = Pathname.new(File.expand_path('../dummy_engine', __dir__))
- require engine_path.join('test/dummy/config/application')
- @rake = Rake::Application.new
- Rake.application = @rake
- stub_const 'APP_RAKEFILE', engine_path.join('test/dummy/Rakefile')
- load 'rails/tasks/engine.rake'
- end
-
- it 'sucessfully runs rake db:migrate in the engine root' do
- expect { Rake::Task['db:migrate'].invoke }.not_to raise_error
- end
-
- it 'sucessfully runs rake app:db:migrate in the engine root' do
- expect { Rake::Task['app:db:migrate'].invoke }.not_to raise_error
- end
-
- context 'when Apartment.db_migrate_tenants is false' do
- it 'should not enhance tasks' do
- Apartment.db_migrate_tenants = false
- expect(Apartment::RakeTaskEnhancer).not_to receive(:enhance_task).with('db:migrate')
- Rake::Task['db:migrate'].invoke
- end
- end
-end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
new file mode 100644
index 00000000..8753e88a
--- /dev/null
+++ b/spec/rails_helper.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+# spec/rails_helper.rb
+
+require 'spec_helper'
+# Set up the Rails environment for testing
+ENV['RAILS_ENV'] ||= 'test'
+
+require_relative 'dummy/config/environment' # Load the Dummy app
+
+require 'rspec/rails' # Load RSpec-Rails
+
+RSpec.configure do |config|
+ # config.filter_run_excluding(database: lambda { |engine|
+ # case ENV.fetch('DATABASE_ENGINE', nil)
+ # when 'mysql'
+ # %i[sqlite postgresql].include?(engine)
+ # when 'sqlite'
+ # %i[mysql postgresql].include?(engine)
+ # when 'postgresql'
+ # %i[mysql sqlite].include?(engine)
+ # else
+ # false
+ # end
+ # })
+end
diff --git a/spec/schemas/v1.rb b/spec/schemas/v1.rb
deleted file mode 100644
index 052f5663..00000000
--- a/spec/schemas/v1.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-# This file is auto-generated from the current state of the database. Instead
-# of editing this file, please use the migrations feature of Active Record to
-# incrementally modify your database, and then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
-ActiveRecord::Schema.define(version: 0) do
-end
diff --git a/spec/schemas/v2.rb b/spec/schemas/v2.rb
deleted file mode 100644
index baf7b998..00000000
--- a/spec/schemas/v2.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# frozen_string_literal: true
-# This file is auto-generated from the current state of the database. Instead
-# of editing this file, please use the migrations feature of Active Record to
-# incrementally modify your database, and then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
-ActiveRecord::Schema.define(version: 20110613152810) do
- create_table 'companies', force: true do |t|
- t.boolean 'dummy'
- t.string 'database'
- end
-
- create_table 'delayed_jobs', force: true do |t|
- t.integer 'priority', default: 0
- t.integer 'attempts', default: 0
- t.text 'handler'
- t.text 'last_error'
- t.datetime 'run_at'
- t.datetime 'locked_at'
- t.datetime 'failed_at'
- t.string 'locked_by'
- t.datetime 'created_at'
- t.datetime 'updated_at'
- t.string 'queue'
- end
-
- add_index 'delayed_jobs', ['priority', 'run_at'], name: 'delayed_jobs_priority'
-
- create_table 'users', force: true do |t|
- t.string 'name'
- t.datetime 'birthdate'
- t.string 'sex'
- end
-end
diff --git a/spec/schemas/v3.rb b/spec/schemas/v3.rb
deleted file mode 100644
index 2cd09a57..00000000
--- a/spec/schemas/v3.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-# This file is auto-generated from the current state of the database. Instead
-# of editing this file, please use the migrations feature of Active Record to
-# incrementally modify your database, and then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your
-# database schema. If you need to create the application database on another
-# system, you should be using db:schema:load, not running all the migrations
-# from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
-ActiveRecord::Schema.define(version: 20111202022214) do
- create_table 'books', force: true do |t|
- t.string 'name'
- t.integer 'pages'
- t.datetime 'published'
- end
-
- create_table 'companies', force: true do |t|
- t.boolean 'dummy'
- t.string 'database'
- end
-
- create_table 'delayed_jobs', force: true do |t|
- t.integer 'priority', default: 0
- t.integer 'attempts', default: 0
- t.text 'handler'
- t.text 'last_error'
- t.datetime 'run_at'
- t.datetime 'locked_at'
- t.datetime 'failed_at'
- t.string 'locked_by'
- t.datetime 'created_at'
- t.datetime 'updated_at'
- t.string 'queue'
- end
-
- add_index 'delayed_jobs', ['priority', 'run_at'], name: 'delayed_jobs_priority'
-
- create_table 'users', force: true do |t|
- t.string 'name'
- t.datetime 'birthdate'
- t.string 'sex'
- end
-end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index c3511ef0..dc90fc4a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,5 +1,13 @@
# frozen_string_literal: true
+require 'bundler/setup'
+
+# Load Rails and ActiveRecord explicitly before bundler require
+require 'rails'
+require 'active_record'
+
+Bundler.require(:default, :test)
+
if ENV['CI'].eql?('true') # ENV['CI'] defined as true by GitHub Actions
require 'simplecov'
require 'simplecov_json_formatter'
@@ -7,74 +15,23 @@
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
SimpleCov.start do
- track_files('lib/**/*.rb')
- add_filter(%r{spec(/|\.)})
- end
-end
-
-$LOAD_PATH.unshift(File.dirname(__FILE__))
-
-# Configure Rails Environment
-ENV['RAILS_ENV'] = 'test'
-
-require File.expand_path('dummy/config/environment.rb', __dir__)
+ add_filter '/spec/'
-# Loading dummy applications affects table_name of each excluded models
-# defined in `spec/dummy/config/initializers/apartment.rb`.
-# To make them pristine, we need to execute below lines.
-Apartment.excluded_models.each do |model|
- klass = model.constantize
-
- klass.remove_connection
- klass.connection_handler.clear_all_connections!
- klass.reset_table_name
+ # add_group 'Adapter', 'lib/apartment/adapters'
+ # add_group 'Elevators', 'lib/apartment/elevators'
+ # add_group 'Core', 'lib/apartment'
+ end
end
-require 'rspec/rails'
-
-ActionMailer::Base.delivery_method = :test
-ActionMailer::Base.perform_deliveries = true
-ActionMailer::Base.default_url_options[:host] = 'test.com'
-
-Rails.backtrace_cleaner.remove_silencers!
+require_relative '../lib/apartment' # Load the Apartment gem
-# Load support files
-Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
+# Include any support files or helpers
+# Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
RSpec.configure do |config|
- config.include(Apartment::Spec::Setup)
-
- # Somewhat brutal hack so that rails 4 postgres extensions don't modify this file
- # rubocop:disable RSpec/BeforeAfterAll
- config.after(:all) do
- `git checkout -- spec/dummy/db/schema.rb`
- end
- # rubocop:enable RSpec/BeforeAfterAll
-
- # rspec-rails 3 will no longer automatically infer an example group's spec type
- # from the file location. You can explicitly opt-in to the feature using this
- # config option.
- # To explicitly tag specs without using automatic inference, set the `:type`
- # metadata manually:
- #
- # describe ThingsController, :type => :controller do
- # # Equivalent to being in spec/controllers
- # end
- config.infer_spec_type_from_file_location!
-
- config.filter_run_excluding(database: lambda { |engine|
- case ENV.fetch('DATABASE_ENGINE', nil)
- when 'mysql'
- %i[sqlite postgresql].include?(engine)
- when 'sqlite'
- %i[mysql postgresql].include?(engine)
- when 'postgresql'
- %i[mysql sqlite].include?(engine)
- else
- false
- end
- })
+ config.disable_monkey_patching!
+ config.filter_run_when_matching(:focus)
end
-# Load shared examples, must happen after configure for RSpec 3
-Dir["#{File.dirname(__FILE__)}/examples/**/*.rb"].each { |f| require f }
+# Load shared examples
+# Dir["#{File.dirname(__FILE__)}/examples/**/*.rb"].each { |f| require f }
diff --git a/spec/support/apartment_helpers.rb b/spec/support/apartment_helpers.rb
deleted file mode 100644
index 0641b13f..00000000
--- a/spec/support/apartment_helpers.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# frozen_string_literal: true
-
-module Apartment
- module Test
- # rubocop:disable Style/ModuleFunction
- extend self
- # rubocop:enable Style/ModuleFunction
-
- def reset
- Apartment.excluded_models = nil
- Apartment.use_schemas = nil
- Apartment.seed_after_create = nil
- Apartment.default_tenant = nil
- end
-
- def next_db
- @x ||= 0
- format('db%