combustion 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fe7aab6e68f602f2b368bc8fa1b0bdeadc34a72eacd4b9d3c30ce6f6dfd6d9c
4
- data.tar.gz: 7342be839ec93b552be92ba789f8dc1d102b8ceeb301fe9e0ad820724dfd4ebf
3
+ metadata.gz: f28e971887ec1b8cccd6708b6a5959fd16dc5afb5e3a1983f002385c3ecbf7a8
4
+ data.tar.gz: b7b4126b5923c1aa847fac7a4b8a2d43d0f8e06aed9fe21cfe62a11c9c5991ba
5
5
  SHA512:
6
- metadata.gz: 04bba0ac0ac7d86e114549ff9e59e9f35098238b2dc1774254bcfab367938467c9b88790d3a45f17ff50d8c0865d7b9691da25b1b8fdcf6489bebd260880b241
7
- data.tar.gz: 8bce1e790cd64eb3c9fc24cfa83d53c1a2627b7fcf82b6ea8759bc856247b92c22a18cd3820b8b41d9f37cc957c6816875991d80c2681baf59bd1a7709cea2ca
6
+ metadata.gz: ff71dda123358ad658f97c536a7a9e1b8d16d2fc8d00518d126677bb408fb3947ec13e428fd335d3be77bad71a0d6f706dc9b0cc3f681e8b0375c29ff447027c
7
+ data.tar.gz: 66eaf6b8b3959dc114326a5b7fc73ead3b47a96a11a9bb21c528efcba59349a07eae6ed09430af2fa2f744e74100f99557cc8bf5f71b970fa144e504268c22bb
data/HISTORY CHANGED
@@ -1,3 +1,7 @@
1
+ 0.9.0 - March 26th 2018
2
+ * Only reset databases that are either custom or the current one (Moritz Winter).
3
+ * More consistency around environment handling (rather than presuming it's always the test environment).
4
+
1
5
  0.8.0 - February 1st 2018
2
6
  * Rails 5.2.0 support.
3
7
  * Requiring digest from std-lib directly.
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', '~> 0.8.0'
13
+ gem.add_development_dependency 'combustion', '~> 0.9.0'
14
14
 
15
15
  # Gemfile
16
- gem 'combustion', '~> 0.8.0', :group => :test
16
+ gem 'combustion', '~> 0.9.0', :group => :test
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:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "combustion"
5
- s.version = "0.8.0"
5
+ s.version = "0.9.0"
6
6
  s.authors = ["Pat Allan"]
7
7
  s.email = ["pat@freelancing-gods.com"]
8
8
  s.homepage = "https://github.com/pat/combustion"
@@ -12,6 +12,8 @@ class Combustion::Database::Reset
12
12
  Combustion::Databases::Firebird => %w[ firebird ]
13
13
  }.freeze
14
14
 
15
+ RAILS_DEFAULT_ENVIRONMENTS = %w[ development production test ].freeze
16
+
15
17
  def self.call
16
18
  new.call
17
19
  end
@@ -23,7 +25,7 @@ class Combustion::Database::Reset
23
25
  end
24
26
 
25
27
  def call
26
- ActiveRecord::Base.configurations.each_value do |configuration|
28
+ resettable_db_configs.each_value do |configuration|
27
29
  adapter = configuration["adapter"] ||
28
30
  configuration["url"].split("://").first
29
31
 
@@ -46,4 +48,16 @@ class Combustion::Database::Reset
46
48
 
47
49
  raise UnsupportedDatabase, "Unsupported database type: #{adapter}"
48
50
  end
51
+
52
+ # All database configs except Rails default environments
53
+ # that are not currently in use
54
+ def resettable_db_configs
55
+ unused_environments = RAILS_DEFAULT_ENVIRONMENTS - [Rails.env.to_s]
56
+ resettable_environments = ActiveRecord::Base.configurations.keys -
57
+ unused_environments
58
+
59
+ ActiveRecord::Base.configurations.select do |name|
60
+ resettable_environments.include?(name)
61
+ end
62
+ end
49
63
  end
@@ -11,7 +11,7 @@ class Combustion::Databases::Base
11
11
  drop
12
12
  create
13
13
 
14
- establish_connection(:test)
14
+ establish_connection Rails.env.to_sym
15
15
  end
16
16
 
17
17
  private
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Combustion::Databases::Firebird < Combustion::Databases::Base
4
4
  def reset
5
- establish_connection :test
5
+ establish_connection Rails.env.to_sym
6
6
  connection.recreate_database!
7
7
  end
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Combustion::Databases::Oracle < Combustion::Databases::Base
4
4
  def reset
5
- establish_connection :test
5
+ establish_connection Rails.env.to_sym
6
6
  connection.structure_drop.split(";\n\n").each do |ddl|
7
7
  connection.execute(ddl)
8
8
  end
@@ -20,7 +20,7 @@ module Combustion
20
20
  to eq true
21
21
  end
22
22
 
23
- it "returns test databse for model with default connection" do
23
+ it "returns test database for model with default connection" do
24
24
  expect(Model.connection_config[:database]).to match(/test/)
25
25
  end
26
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: combustion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  version: '0'
232
232
  requirements: []
233
233
  rubyforge_project: combustion
234
- rubygems_version: 2.7.3
234
+ rubygems_version: 2.7.6
235
235
  signing_key:
236
236
  specification_version: 4
237
237
  summary: Elegant Rails Engine Testing