combustion 1.1.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Appraisals +9 -1
- data/Gemfile +12 -1
- data/README.md +4 -4
- data/lib/combustion.rb +22 -8
- data/lib/combustion/application.rb +9 -3
- data/lib/combustion/configurations/active_storage.rb +9 -0
- data/lib/combustion/database/migrate.rb +7 -1
- data/lib/combustion/database/reset.rb +36 -8
- data/lib/combustion/databases/mysql.rb +15 -15
- data/lib/combustion/databases/postgresql.rb +7 -7
- data/lib/combustion/databases/sql_server.rb +2 -2
- data/lib/combustion/databases/sqlite.rb +2 -2
- data/lib/combustion/generator.rb +5 -2
- data/spec/database_spec.rb +21 -20
- data/spec/dummy/spec/internal/app/assets/config/manifest.js +1 -0
- data/spec/dummy/spec/internal/log/development.log +52 -0
- data/spec/dummy/spec/internal/log/test.log +4840 -0
- data/spec/dummy/spec/internal/test +0 -0
- data/spec/dummy/spec/internal/test_another +0 -0
- data/spec/spec_helper.rb +4 -1
- data/templates/storage.yml +3 -0
- metadata +27 -27
- data/.gitignore +0 -11
- data/.rubocop.yml +0 -39
- data/.travis.yml +0 -23
- data/HISTORY +0 -99
- data/combustion.gemspec +0 -34
- data/gemfiles/rails_3.1.gemfile +0 -9
- data/gemfiles/rails_3.2.gemfile +0 -9
- data/gemfiles/rails_4.0.gemfile +0 -9
- data/gemfiles/rails_4.1.gemfile +0 -9
- data/gemfiles/rails_4.2.gemfile +0 -9
- data/gemfiles/rails_5.0.gemfile +0 -9
- data/gemfiles/rails_5.1.gemfile +0 -9
- data/gemfiles/rails_5.2.gemfile +0 -8
- data/gemfiles/rails_5_0.gemfile +0 -7
- data/spec/dummy/spec/internal/log/.gitignore +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6757c9291746515078aa689da7f819b5a3679546b55cd9f2d64d6a2d4ac66f5
|
4
|
+
data.tar.gz: 2b1b3e0f92d8e8b07c1fa8678f88e36b5ceb5cda01246ef4528c95b5d4022429
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec5405a6b9a3219ee33cba45ced79b68850bf6a0d29738af684c94586d6bb6ee3826be5042780cfb131a9f1b3ce38cf11ab3597965c7991f05c0560f1d69aa68
|
7
|
+
data.tar.gz: 736d397893838938051ca0a58c199ea595500adeb9bc40a115c42c2f930020a49ecf31267374286db081974a226e3f178527aa9a2ba318d694e745dacd145542
|
data/Appraisals
CHANGED
@@ -56,7 +56,15 @@ end
|
|
56
56
|
|
57
57
|
if RUBY_VERSION.to_f >= 2.5
|
58
58
|
appraise "rails-6.0" do
|
59
|
-
gem "rails", "~> 6.0.0
|
59
|
+
gem "rails", "~> 6.0.0"
|
60
60
|
gem "mysql2", "~> 0.5.0"
|
61
|
+
gem "sqlite3", "~> 1.4"
|
62
|
+
end
|
63
|
+
|
64
|
+
appraise "rails-edge" do
|
65
|
+
gem "rails", :git => "https://github.com/rails/rails.git"
|
66
|
+
gem "arel", :git => "https://github.com/rails/arel.git"
|
67
|
+
gem "mysql2", "~> 0.5.0"
|
68
|
+
gem "sqlite3", "~> 1.4"
|
61
69
|
end
|
62
70
|
end
|
data/Gemfile
CHANGED
@@ -4,4 +4,15 @@ source "http://rubygems.org"
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem "sqlite3", "~> 1.3.13"
|
7
|
+
gem "sqlite3", "~> 1.3.13"
|
8
|
+
|
9
|
+
if RUBY_VERSION.to_f < 2.3
|
10
|
+
gem "i18n", "< 1.6"
|
11
|
+
gem "nio4r", "< 2.4"
|
12
|
+
gem "nokogiri", "< 1.10.3"
|
13
|
+
end
|
14
|
+
|
15
|
+
if RUBY_VERSION.to_f > 2.4
|
16
|
+
gem "rubocop", "~> 0.92"
|
17
|
+
gem "rubocop-packaging", "~> 0.5"
|
18
|
+
end
|
data/README.md
CHANGED
@@ -10,10 +10,10 @@ Get the gem into either your gemspec or your Gemfile, depending on how you manag
|
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
# gemspec
|
13
|
-
gem.add_development_dependency 'combustion', '~> 1.
|
13
|
+
gem.add_development_dependency 'combustion', '~> 1.3'
|
14
14
|
|
15
15
|
# Gemfile
|
16
|
-
gem 'combustion', '~> 1.
|
16
|
+
gem 'combustion', '~> 1.3'
|
17
17
|
```
|
18
18
|
|
19
19
|
In your `spec_helper.rb`, get Combustion to set itself up - which has to happen before you introduce `rspec/rails` and - if being used - `capybara/rails`. Here's an example within context:
|
@@ -150,7 +150,7 @@ Combustion.initialize! :all do
|
|
150
150
|
end
|
151
151
|
```
|
152
152
|
|
153
|
-
Values given through the initialize! block will be set during Rails initialization
|
153
|
+
Values given through the initialize! block will be set during Rails initialization process, exactly before the corresponding environment file inside `spec/internals/config/enviroments` is loaded (when that file exists), overriding Combustion's defaults.
|
154
154
|
|
155
155
|
Parameters defined in, for instance, `spec/internals/config/environments/test.rb`, would override Combustion's defaults and also config settings passed to initialize!.
|
156
156
|
|
@@ -185,7 +185,7 @@ end
|
|
185
185
|
|
186
186
|
## Compatibility
|
187
187
|
|
188
|
-
The current test matrix covers MRI 2.2 to 2.
|
188
|
+
The current test matrix covers MRI 2.2 to 2.6, and Rails 3.1 to 6.0. It will possibly work on older versions and other Ruby implementations as well.
|
189
189
|
|
190
190
|
You can also use Combustion with multiple versions of Rails to test compatibility across them. [Appraisal](https://github.com/thoughtbot/appraisal) is a gem that can help with this, and a good starting reference is the [Thinking Sphinx](https://github.com/pat/thinking-sphinx) test suite, which runs against [multiple versions](https://github.com/pat/thinking-sphinx/blob/master/Appraisals) of Rails.
|
191
191
|
|
data/lib/combustion.rb
CHANGED
@@ -12,18 +12,31 @@ module Combustion
|
|
12
12
|
self.path = "/spec/internal"
|
13
13
|
self.schema_format = :ruby
|
14
14
|
|
15
|
-
MODULES =
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
MODULES = begin
|
16
|
+
hash = {
|
17
|
+
:active_model => "active_model/railtie",
|
18
|
+
:active_record => "active_record/railtie",
|
19
|
+
:action_controller => "action_controller/railtie",
|
20
|
+
:action_mailer => "action_mailer/railtie",
|
21
|
+
:action_view => "action_view/railtie"
|
22
|
+
}
|
23
|
+
|
24
|
+
hash[:sprockets] = "sprockets/railtie" if Rails.version.to_f >= 3.1
|
25
|
+
hash[:active_job] = "active_job/railtie" if Rails.version.to_f >= 4.2
|
26
|
+
hash[:action_cable] = "action_cable/engine" if Rails.version.to_f >= 5.0
|
27
|
+
hash[:active_storage] = "active_storage/engine" if Rails.version.to_f >= 5.2
|
28
|
+
hash[:action_text] = "action_text/engine" if Rails.version.to_f >= 6.0
|
29
|
+
hash[:action_mailbox] = "action_mailbox/engine" if Rails.version.to_f >= 6.0
|
30
|
+
|
31
|
+
hash
|
32
|
+
end.freeze
|
20
33
|
|
21
34
|
def self.initialize!(*modules, &block)
|
22
35
|
self.setup_environment = block if block_given?
|
23
36
|
|
24
37
|
options = modules.extract_options!
|
25
|
-
modules = MODULES if modules == [:all]
|
26
|
-
modules.each { |mod| require "#{mod}/railtie" }
|
38
|
+
modules = MODULES.keys if modules == [:all]
|
39
|
+
modules.each { |mod| require MODULES.fetch(mod, "#{mod}/railtie") }
|
27
40
|
|
28
41
|
Bundler.require :default, Rails.env
|
29
42
|
|
@@ -65,8 +78,9 @@ module Combustion
|
|
65
78
|
end
|
66
79
|
end
|
67
80
|
|
68
|
-
require "combustion/application"
|
69
81
|
require "combustion/configurations/action_controller"
|
70
82
|
require "combustion/configurations/action_mailer"
|
71
83
|
require "combustion/configurations/active_record"
|
84
|
+
require "combustion/configurations/active_storage"
|
85
|
+
require "combustion/application"
|
72
86
|
require "combustion/database"
|
@@ -6,6 +6,13 @@ Rails.env = ENV["RAILS_ENV"] || "test"
|
|
6
6
|
|
7
7
|
module Combustion
|
8
8
|
class Application < Rails::Application
|
9
|
+
CONFIGURERS = [
|
10
|
+
Combustion::Configurations::ActiveRecord,
|
11
|
+
Combustion::Configurations::ActionController,
|
12
|
+
Combustion::Configurations::ActionMailer,
|
13
|
+
Combustion::Configurations::ActiveStorage
|
14
|
+
].freeze
|
15
|
+
|
9
16
|
version = Rails.version.to_f
|
10
17
|
|
11
18
|
# Core Settings
|
@@ -26,9 +33,7 @@ module Combustion
|
|
26
33
|
def self.configure_for_combustion
|
27
34
|
config.root = File.expand_path File.join(Dir.pwd, Combustion.path)
|
28
35
|
|
29
|
-
|
30
|
-
Combustion::Configurations::ActionController.call config
|
31
|
-
Combustion::Configurations::ActionMailer.call config
|
36
|
+
CONFIGURERS.each { |configurer| configurer.call config }
|
32
37
|
|
33
38
|
config.assets.enabled = true if defined?(Sprockets)
|
34
39
|
end
|
@@ -39,6 +44,7 @@ module Combustion
|
|
39
44
|
:group => :all
|
40
45
|
) do
|
41
46
|
next unless Combustion.setup_environment
|
47
|
+
|
42
48
|
Combustion::Application.class_eval(&Combustion.setup_environment)
|
43
49
|
end
|
44
50
|
end
|
@@ -44,7 +44,13 @@ class Combustion::Database::Migrate
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def migration_context
|
47
|
-
ActiveRecord::MigrationContext.
|
47
|
+
if ActiveRecord::MigrationContext.instance_method(:initialize).arity <= 1
|
48
|
+
ActiveRecord::MigrationContext.new paths
|
49
|
+
else
|
50
|
+
ActiveRecord::MigrationContext.new(
|
51
|
+
paths, ActiveRecord::Base.connection.schema_migration
|
52
|
+
)
|
53
|
+
end
|
48
54
|
end
|
49
55
|
|
50
56
|
def migrator
|
@@ -1,10 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Combustion::Database::Reset
|
4
|
+
# https://github.com/ruby/psych/pull/358/files#diff-fcdbfb11714f576f58ba9f866052bc79R322
|
5
|
+
RUBY_VERSION_WITH_NEW_SAFE_LOAD_METHOD_SIGNATURE = "2.6.0"
|
6
|
+
|
4
7
|
UnsupportedDatabase = Class.new StandardError
|
5
8
|
|
6
9
|
OPERATOR_PATTERNS = {
|
7
|
-
Combustion::Databases::MySQL
|
10
|
+
Combustion::Databases::MySQL => [/mysql/],
|
8
11
|
Combustion::Databases::PostgreSQL => [/postgres/, /postgis/],
|
9
12
|
Combustion::Databases::SQLite => [/sqlite/],
|
10
13
|
Combustion::Databases::SQLServer => [/sqlserver/],
|
@@ -19,15 +22,22 @@ class Combustion::Database::Reset
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def initialize
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
+
# TODO: remove when no longer support 2.5.8
|
26
|
+
if RUBY_VERSION >= RUBY_VERSION_WITH_NEW_SAFE_LOAD_METHOD_SIGNATURE
|
27
|
+
ActiveRecord::Base.configurations = YAML.safe_load(
|
28
|
+
ERB.new(database_yaml).result, :aliases => true
|
29
|
+
)
|
30
|
+
else
|
31
|
+
ActiveRecord::Base.configurations = YAML.safe_load(
|
32
|
+
ERB.new(database_yaml).result, [], [], true
|
33
|
+
)
|
34
|
+
end
|
25
35
|
end
|
26
36
|
|
27
37
|
def call
|
28
|
-
resettable_db_configs.
|
29
|
-
adapter = configuration[
|
30
|
-
configuration[
|
38
|
+
resettable_db_configs.each do |configuration|
|
39
|
+
adapter = configuration[:adapter] ||
|
40
|
+
configuration[:url].split("://").first
|
31
41
|
|
32
42
|
operator_class(adapter).new(configuration).reset
|
33
43
|
end
|
@@ -52,10 +62,28 @@ class Combustion::Database::Reset
|
|
52
62
|
# All database configs except Rails default environments
|
53
63
|
# that are not currently in use
|
54
64
|
def resettable_db_configs
|
65
|
+
if ActiveRecord::VERSION::STRING.to_f > 6.0
|
66
|
+
return resettable_db_configs_for_6_1
|
67
|
+
end
|
68
|
+
|
55
69
|
all_configurations = ActiveRecord::Base.configurations.to_h
|
56
70
|
unused_environments = RAILS_DEFAULT_ENVIRONMENTS - [Rails.env.to_s]
|
57
71
|
resettable_environments = all_configurations.keys - unused_environments
|
58
72
|
|
59
|
-
all_configurations.
|
73
|
+
all_configurations.
|
74
|
+
select { |name| resettable_environments.include?(name) }.
|
75
|
+
values.
|
76
|
+
collect(&:with_indifferent_access)
|
77
|
+
end
|
78
|
+
|
79
|
+
def resettable_db_configs_for_6_1
|
80
|
+
all_configurations = ActiveRecord::Base.configurations.configurations
|
81
|
+
unused_environments = RAILS_DEFAULT_ENVIRONMENTS - [Rails.env.to_s]
|
82
|
+
resettable_environments = all_configurations.collect(&:env_name).uniq -
|
83
|
+
unused_environments
|
84
|
+
|
85
|
+
all_configurations.
|
86
|
+
select { |config| resettable_environments.include?(config.env_name) }.
|
87
|
+
collect(&:configuration_hash)
|
60
88
|
end
|
61
89
|
end
|
@@ -4,7 +4,7 @@ class Combustion::Databases::MySQL < Combustion::Databases::Base
|
|
4
4
|
ACCESS_DENIED_ERROR = 10_145
|
5
5
|
|
6
6
|
def reset
|
7
|
-
establish_connection(configuration.merge(
|
7
|
+
establish_connection(configuration.merge(:database => nil))
|
8
8
|
|
9
9
|
super
|
10
10
|
end
|
@@ -12,21 +12,21 @@ class Combustion::Databases::MySQL < Combustion::Databases::Base
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def charset
|
15
|
-
configuration[
|
15
|
+
configuration[:charset] || ENV["CHARSET"] || "utf8"
|
16
16
|
end
|
17
17
|
|
18
18
|
def charset_error
|
19
|
-
return "" unless
|
19
|
+
return "" unless configuration[:charset]
|
20
20
|
|
21
21
|
"(if you set the charset manually, make sure you have a matching collation)"
|
22
22
|
end
|
23
23
|
|
24
24
|
def collation
|
25
|
-
configuration[
|
25
|
+
configuration[:collation] || ENV["COLLATION"] || "utf8_unicode_ci"
|
26
26
|
end
|
27
27
|
|
28
28
|
def create
|
29
|
-
connection.create_database configuration[
|
29
|
+
connection.create_database configuration[:database], creation_options
|
30
30
|
establish_connection configuration
|
31
31
|
rescue error_class => error
|
32
32
|
rescue_create_from error
|
@@ -34,12 +34,12 @@ class Combustion::Databases::MySQL < Combustion::Databases::Base
|
|
34
34
|
|
35
35
|
def create_as_root(error)
|
36
36
|
establish_connection configuration.merge(
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
:database => nil,
|
38
|
+
:username => "root",
|
39
|
+
:password => request_password(error)
|
40
40
|
)
|
41
41
|
|
42
|
-
connection.create_database
|
42
|
+
connection.create_database configuration[:database], creation_options
|
43
43
|
connection.execute grant_statement
|
44
44
|
|
45
45
|
establish_connection configuration
|
@@ -50,15 +50,15 @@ class Combustion::Databases::MySQL < Combustion::Databases::Base
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def drop
|
53
|
-
connection.drop_database configuration[
|
53
|
+
connection.drop_database configuration[:database]
|
54
54
|
end
|
55
55
|
|
56
56
|
def error_class
|
57
|
-
if configuration[
|
57
|
+
if configuration[:adapter][/jdbc/]
|
58
58
|
# FIXME: After Jdbcmysql gives this class
|
59
59
|
require "active_record/railties/jdbcmysql_error"
|
60
60
|
ArJdbcMySQL::Error
|
61
|
-
elsif
|
61
|
+
elsif configuration[:adapter][/mysql2/] && defined?(Mysql2)
|
62
62
|
Mysql2::Error
|
63
63
|
else
|
64
64
|
Mysql::Error
|
@@ -68,8 +68,8 @@ class Combustion::Databases::MySQL < Combustion::Databases::Base
|
|
68
68
|
def grant_statement
|
69
69
|
<<-SQL
|
70
70
|
GRANT ALL PRIVILEGES ON #{configuration["database"]}.*
|
71
|
-
TO '#{configuration[
|
72
|
-
IDENTIFIED BY '#{configuration[
|
71
|
+
TO '#{configuration[:username]}'@'localhost'
|
72
|
+
IDENTIFIED BY '#{configuration[:password]}' WITH GRANT OPTION;
|
73
73
|
SQL
|
74
74
|
end
|
75
75
|
|
@@ -91,7 +91,7 @@ Please provide the root password for your mysql installation
|
|
91
91
|
|
92
92
|
warn <<-TXT
|
93
93
|
#{error.error}
|
94
|
-
Couldn't create database for #{
|
94
|
+
Couldn't create database for #{configuration.inspect}, charset: #{charset}, collation: #{collation}
|
95
95
|
#{charset_error}
|
96
96
|
TXT
|
97
97
|
end
|
@@ -12,8 +12,8 @@ class Combustion::Databases::PostgreSQL < Combustion::Databases::Base
|
|
12
12
|
|
13
13
|
def create
|
14
14
|
connection.create_database(
|
15
|
-
configuration[
|
16
|
-
configuration.merge(
|
15
|
+
configuration[:database],
|
16
|
+
configuration.merge(:encoding => encoding)
|
17
17
|
)
|
18
18
|
rescue StandardError => error
|
19
19
|
warn error, *error.backtrace
|
@@ -21,21 +21,21 @@ class Combustion::Databases::PostgreSQL < Combustion::Databases::Base
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def drop
|
24
|
-
connection.drop_database(configuration[
|
24
|
+
connection.drop_database(configuration[:database])
|
25
25
|
end
|
26
26
|
|
27
27
|
def encoding
|
28
|
-
configuration[
|
28
|
+
configuration[:encoding] || ENV["CHARSET"] || "utf8"
|
29
29
|
end
|
30
30
|
|
31
31
|
def postgres_configuration
|
32
32
|
configuration.merge(
|
33
|
-
|
34
|
-
|
33
|
+
:database => "postgres",
|
34
|
+
:schema_search_path => schema_search_path
|
35
35
|
)
|
36
36
|
end
|
37
37
|
|
38
38
|
def schema_search_path
|
39
|
-
configuration[
|
39
|
+
configuration[:adapter][/postgis/] ? "public, postgis" : "public"
|
40
40
|
end
|
41
41
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
class Combustion::Databases::SQLServer < Combustion::Databases::Base
|
4
4
|
def reset
|
5
|
-
establish_connection configuration.merge(
|
6
|
-
connection.recreate_database! configuration[
|
5
|
+
establish_connection configuration.merge(:database => "master")
|
6
|
+
connection.recreate_database! configuration[:database]
|
7
7
|
end
|
8
8
|
end
|
@@ -8,7 +8,7 @@ class Combustion::Databases::SQLite < Combustion::Databases::Base
|
|
8
8
|
|
9
9
|
def create
|
10
10
|
if exists?
|
11
|
-
warn "#{config[
|
11
|
+
warn "#{config[:database]} already exists"
|
12
12
|
return
|
13
13
|
end
|
14
14
|
|
@@ -32,6 +32,6 @@ class Combustion::Databases::SQLite < Combustion::Databases::Base
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def path
|
35
|
-
@path ||= Pathname.new configuration[
|
35
|
+
@path ||= Pathname.new configuration[:database]
|
36
36
|
end
|
37
37
|
end
|
data/lib/combustion/generator.rb
CHANGED
@@ -23,8 +23,11 @@ module Combustion
|
|
23
23
|
template "templates/database.yml", "spec/internal/config/database.yml"
|
24
24
|
template "templates/schema.rb", "spec/internal/db/schema.rb"
|
25
25
|
template "templates/config.ru", "config.ru"
|
26
|
-
|
27
|
-
|
26
|
+
template "templates/storage.yml", "spec/internal/config/storage.yml"
|
27
|
+
|
28
|
+
create_file "spec/internal/app/assets/config/manifest.js"
|
29
|
+
create_file "spec/internal/public/favicon.ico"
|
30
|
+
create_file "spec/internal/log/.gitignore" do
|
28
31
|
"*.log"
|
29
32
|
end
|
30
33
|
end
|
data/spec/database_spec.rb
CHANGED
@@ -1,30 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it "creates dummy table from migration in base database" do
|
12
|
-
expect(Model.connection.table_exists?("dummy_table")).to eq true
|
13
|
-
expect(Model.connection.table_exists?("dummy_in_another_db")).to eq false
|
14
|
-
end
|
3
|
+
RSpec.describe Combustion::Database do
|
4
|
+
it "creates dummy table from migration in base database" do
|
5
|
+
expect(Model.connection.table_exists?("dummy_table")).to eq true
|
6
|
+
expect(Model.connection.table_exists?("dummy_in_another_db")).to eq false
|
7
|
+
end
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
it "creates another dummy table from another database" do
|
10
|
+
expect(ModelInAnotherDb.connection.table_exists?("dummy_table")).
|
11
|
+
to eq false
|
12
|
+
expect(ModelInAnotherDb.connection.table_exists?("dummy_in_another_db")).
|
13
|
+
to eq true
|
14
|
+
end
|
22
15
|
|
23
|
-
|
16
|
+
it "returns test database for model with default connection" do
|
17
|
+
if ActiveRecord::VERSION::STRING.to_f > 6.0
|
18
|
+
expect(Model.connection_db_config.database).to match(/test/)
|
19
|
+
else
|
24
20
|
expect(Model.connection_config[:database]).to match(/test/)
|
25
21
|
end
|
22
|
+
end
|
26
23
|
|
27
|
-
|
24
|
+
it "returns test_another for model with connection to second database" do
|
25
|
+
if ActiveRecord::VERSION::STRING.to_f > 6.0
|
26
|
+
expect(ModelInAnotherDb.connection_db_config.database).
|
27
|
+
to match(/test_another/)
|
28
|
+
else
|
28
29
|
expect(ModelInAnotherDb.connection_config[:database]).
|
29
30
|
to match(/test_another/)
|
30
31
|
end
|