combustion 1.3.3 → 1.3.6

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: 97053abef57625a082cfc03848c5822384541e7badc99ad7eda77729eca45e11
4
- data.tar.gz: 69afc4e110cc230359c021ee0ed7820241af3bfeaeff0229c441594225c4d732
3
+ metadata.gz: 8736ae93f4eac4f43a47ebdd063f4ad227f307dd973536ab710a5584ed29976d
4
+ data.tar.gz: 880e055549466b9c7203a2f34fd437addc3b580b0a100ca4b5aa2cef7ba4bce8
5
5
  SHA512:
6
- metadata.gz: b4e662dede67e6e44ba8fc570277190e330948f2b73dd1b71067a5caee84d6171a63a54967a56246d06544c6458dbb57c0c2b28ef15401a173fe0f917b47debb
7
- data.tar.gz: 1035a1e6b7c2b8b6a4b4d4d1e7bf95838b76a9720db2f240d42abd5c8a55e0318cd54360ccf689118138155254f60fc7ded4cde6cb5437f7f132b233b24753c1
6
+ metadata.gz: ade36f7e179e4ba4743a75ba8de7f7223a2651a2d1c9f008775a0895f91eb8cec96b8cd94a47768964d1927edfe0af8b5d05bbd6f90295276117fedbd34c5793
7
+ data.tar.gz: b0320150a0db6dc3b66292392abf45efb54c26aea963810479143f43ed4dae2cf4799c2118567c9dc4ccf4ae807bee3531c3f41f78eccf635c2d85e89b4d753f
data/Appraisals CHANGED
@@ -56,13 +56,15 @@ if RUBY_VERSION.to_f < 3.0
56
56
  end
57
57
  end
58
58
 
59
- if RUBY_VERSION.to_f >= 2.5
59
+ if RUBY_VERSION.to_f >= 2.5 && RUBY_VERSION.to_f < 3.1
60
60
  appraise "rails-6.0" do
61
61
  gem "rails", "~> 6.0.0"
62
62
  gem "mysql2", "~> 0.5.0"
63
63
  gem "sqlite3", "~> 1.4"
64
64
  end
65
+ end
65
66
 
67
+ if RUBY_VERSION.to_f >= 2.5
66
68
  appraise "rails-6.1" do
67
69
  gem "rails", "~> 6.1.0"
68
70
  gem "mysql2", "~> 0.5.0"
@@ -72,7 +74,7 @@ end
72
74
 
73
75
  if RUBY_VERSION.to_f >= 2.7
74
76
  appraise "rails-7.0" do
75
- gem "rails", "~> 7.0.0.alpha2"
77
+ gem "rails", "~> 7.0.1"
76
78
  gem "mysql2", "~> 0.5.0"
77
79
  gem "sqlite3", "~> 1.4"
78
80
  end
data/Gemfile CHANGED
@@ -20,3 +20,6 @@ if RUBY_VERSION.to_f > 2.4
20
20
  gem "rubocop", "~> 0.92"
21
21
  gem "rubocop-packaging", "~> 0.5"
22
22
  end
23
+
24
+ # Required for testing Rails 6.1 on MRI 3.1+
25
+ gem "net-smtp" if RUBY_VERSION.to_f > 3.0
data/README.md CHANGED
@@ -37,6 +37,8 @@ RSpec.configure do |config|
37
37
  end
38
38
  ```
39
39
 
40
+ Please note that using `:all` as an argument for `Combustion.initialize!` will load all key parts of Rails that are considered essential for that version. For example: ActiveJob is only loaded for Rails 4.2 onwards, and Sprockets is only loaded for Rails 3.1-6.1 (as it is no longer part of the default set in 7.0).
41
+
40
42
  You'll also want to run the generator that creates a minimal set of files expected by Rails - run this in the directory of your engine:
41
43
 
42
44
  ```shell
@@ -156,7 +158,7 @@ Parameters defined in, for instance, `spec/internals/config/environments/test.rb
156
158
 
157
159
  ### Using other Rails-focused libraries
158
160
 
159
- Be aware that other gems may require parts of Rails when they're loaded, and this could cause some issues with Combustion's own setup. You may need to manage the loading yourself by setting `:require` to false in your Gemfile for the gem in question, and then requiring it manually in your spec_helper. View [issue #33](https://github.com/pat/combustion/issues/33) for an example with FactoryGirl.
161
+ Be aware that other gems may require parts of Rails when they're loaded, and this could cause some issues with Combustion's own setup. You may need to manage the loading yourself by setting `:require` to false in your Gemfile for the gem in question, and then requiring it manually in your spec_helper. View [issue #33](https://github.com/pat/combustion/issues/33) for an example with FactoryBot.
160
162
 
161
163
  ### Environment and Logging
162
164
 
@@ -185,7 +187,7 @@ end
185
187
 
186
188
  ## Compatibility
187
189
 
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.
190
+ The current test matrix covers MRI 2.4 to 3.1, and Rails 3.1 to 7.0. It will possibly work on older versions and other Ruby implementations as well.
189
191
 
190
192
  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
193
 
@@ -13,16 +13,18 @@ module Combustion
13
13
  Combustion::Configurations::ActiveStorage
14
14
  ].freeze
15
15
 
16
- version = Rails.version.to_f
16
+ rails_gate = VersionGate.new("rails")
17
17
 
18
18
  # Core Settings
19
19
  config.cache_classes = true
20
20
  config.consider_all_requests_local = true
21
21
  config.eager_load = Rails.env.production?
22
22
 
23
- config.secret_key_base = SecureRandom.hex if version >= 4.0
24
- config.whiny_nils = true if version < 4.0
25
- config.secret_token = Digest::SHA1.hexdigest Time.now.to_s if version < 5.2
23
+ config.secret_key_base = SecureRandom.hex if rails_gate.call(">= 4.0")
24
+ config.whiny_nils = true if rails_gate.call("< 4")
25
+ if rails_gate.call("< 5.2")
26
+ config.secret_token = Digest::SHA1.hexdigest Time.now.to_s
27
+ end
26
28
 
27
29
  # ActiveSupport Settings
28
30
  config.active_support.deprecation = :stderr
@@ -3,12 +3,13 @@
3
3
  class Combustion::Configurations::ActiveRecord
4
4
  def self.call(config)
5
5
  return unless defined?(ActiveRecord::Railtie)
6
- return unless ::ActiveRecord.constants.include?(:MassAssignmentSecurity)
7
6
 
8
- if ActiveRecord::VERSION::MAJOR >= 7
7
+ if Combustion::VersionGate.call("activerecord", "~> 7.0.0")
9
8
  config.active_record.legacy_connection_handling = false
10
9
  end
11
10
 
11
+ return unless ::ActiveRecord.constants.include?(:MassAssignmentSecurity)
12
+
12
13
  # Turn on ActiveRecord attribute whitelisting
13
14
  # This way the dummy app matches new rails apps re: this setting
14
15
  config.active_record.whitelist_attributes = true
@@ -6,9 +6,11 @@ class Combustion::Database::Migrate
6
6
  end
7
7
 
8
8
  def call
9
- if ActiveRecord::VERSION::STRING.to_f >= 5.2
9
+ ar_gate = Combustion::VersionGate.new("activerecord")
10
+
11
+ if ar_gate.call(">= 5.2")
10
12
  migration_context.migrate
11
- elsif ActiveRecord::VERSION::STRING.to_f >= 3.1
13
+ elsif ar_gate.call(">= 3.1")
12
14
  migrator.migrate paths, nil
13
15
  else
14
16
  paths.each { |path| migrator.migrate path, nil }
@@ -62,7 +62,7 @@ class Combustion::Database::Reset
62
62
  # All database configs except Rails default environments
63
63
  # that are not currently in use
64
64
  def resettable_db_configs
65
- if ActiveRecord::VERSION::STRING.to_f > 6.0
65
+ if Combustion::VersionGate.call("activerecord", ">= 6.1")
66
66
  return resettable_db_configs_for_6_1
67
67
  end
68
68
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+
5
+ module Combustion
6
+ class VersionGate
7
+ def self.call(name, *constraints)
8
+ new(name).call(*constraints)
9
+ end
10
+
11
+ def initialize(name)
12
+ @name = name
13
+ end
14
+
15
+ # Using matches_spec? instead of match? because the former returns true
16
+ # even when the spec has an appropriate _pre-release_ version.
17
+ def call(*constraints)
18
+ return false if spec.nil?
19
+
20
+ dependency(*constraints).matches_spec?(spec)
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :name
26
+
27
+ def dependency(*constraints)
28
+ Gem::Dependency.new(name, *constraints)
29
+ end
30
+
31
+ def spec
32
+ Gem.loaded_specs.fetch(name, nil)
33
+ end
34
+ end
35
+ end
data/lib/combustion.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  require "rails"
4
4
  require "active_support/dependencies"
5
5
 
6
+ require "combustion/version_gate"
7
+
6
8
  module Combustion
7
9
  module Configurations
8
10
  end
@@ -12,30 +14,39 @@ module Combustion
12
14
  self.path = "/spec/internal"
13
15
  self.schema_format = :ruby
14
16
 
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
17
+ MODULES = {
18
+ :active_model => "active_model/railtie",
19
+ :active_record => "active_record/railtie",
20
+ :action_controller => "action_controller/railtie",
21
+ :action_mailer => "action_mailer/railtie",
22
+ :action_view => "action_view/railtie",
23
+ :sprockets => "sprockets/railtie",
24
+ :active_job => "active_job/railtie",
25
+ :action_cable => "action_cable/engine",
26
+ :active_storage => "active_storage/engine",
27
+ :action_text => "action_text/engine",
28
+ :action_mailbox => "action_mailbox/engine"
29
+ }.freeze
30
+
31
+ AVAILABLE_MODULES = begin
32
+ keys = MODULES.keys
33
+ rails_gate = VersionGate.new("rails")
34
+
35
+ keys.delete(:sprockets) unless rails_gate.call(">= 3.1", "<= 6.1")
36
+ keys.delete(:active_job) unless rails_gate.call(">= 4.2")
37
+ keys.delete(:action_cable) unless rails_gate.call(">= 5.0")
38
+ keys.delete(:active_storage) unless rails_gate.call(">= 5.2")
39
+ keys.delete(:action_text) unless rails_gate.call(">= 6.0")
40
+ keys.delete(:action_mailbox) unless rails_gate.call(">= 6.0")
41
+
42
+ keys
32
43
  end.freeze
33
44
 
34
45
  def self.initialize!(*modules, &block)
35
46
  self.setup_environment = block if block_given?
36
47
 
37
48
  options = modules.extract_options!
38
- modules = MODULES.keys if modules == [:all]
49
+ modules = AVAILABLE_MODULES if modules == [:all]
39
50
  modules.each { |mod| require MODULES.fetch(mod, "#{mod}/railtie") }
40
51
 
41
52
  Bundler.require :default, Rails.env
@@ -14,15 +14,15 @@ RSpec.describe Combustion::Database do
14
14
  end
15
15
 
16
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/)
17
+ if Combustion::VersionGate.call("activerecord", ">= 6.1")
18
+ expect(Model.connection_db_config.database).to match(/combustion/)
19
19
  else
20
- expect(Model.connection_config[:database]).to match(/test/)
20
+ expect(Model.connection_config[:database]).to match(/combustion/)
21
21
  end
22
22
  end
23
23
 
24
24
  it "returns test_another for model with connection to second database" do
25
- if ActiveRecord::VERSION::STRING.to_f > 6.0
25
+ if Combustion::VersionGate.call("activerecord", ">= 6.1")
26
26
  expect(ModelInAnotherDb.connection_db_config.database).
27
27
  to match(/test_another/)
28
28
  else
Binary file
@@ -1,6 +1,6 @@
1
1
  test: &defaults
2
2
  adapter: <%= ENV.fetch("DB_ADAPTER") %>
3
- database: test
3
+ database: combustion
4
4
  <% if ENV["DB_HOST"] %>
5
5
  host: <%= ENV["DB_HOST"] %>
6
6
  <% end %>
@@ -13,6 +13,10 @@ test: &defaults
13
13
  password: <%= ENV["DB_PASSWORD"] %>
14
14
  <% end %>
15
15
 
16
+ <% if ENV["DB_PORT"] %>
17
+ port: <%= ENV["DB_PORT"] %>
18
+ <% end %>
19
+
16
20
 
17
21
  test_another:
18
22
  <<: *defaults
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "combustion"
4
4
 
5
- if Rails::VERSION::STRING.to_f < 4.1
5
+ if Combustion::VersionGate.call("rails", "< 4.1")
6
6
  require "active_record"
7
7
  require "active_record/connection_adapters/mysql2_adapter"
8
8
 
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: 1.3.3
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -183,6 +183,7 @@ files:
183
183
  - lib/combustion/databases/sql_server.rb
184
184
  - lib/combustion/databases/sqlite.rb
185
185
  - lib/combustion/generator.rb
186
+ - lib/combustion/version_gate.rb
186
187
  - spec/database_spec.rb
187
188
  - spec/dummy/db/migrate/20150717075542_create_dummy_test_table.rb
188
189
  - spec/dummy/db/migrate/20150717075543_create_dummy_test_table_in_another_db.rb
@@ -190,6 +191,7 @@ files:
190
191
  - spec/dummy/spec/internal/app/assets/config/manifest.js
191
192
  - spec/dummy/spec/internal/app/models/model.rb
192
193
  - spec/dummy/spec/internal/app/models/model_in_another_db.rb
194
+ - spec/dummy/spec/internal/combustion
193
195
  - spec/dummy/spec/internal/config/database.yml
194
196
  - spec/dummy/spec/internal/config/routes.rb
195
197
  - spec/dummy/spec/internal/db/schema.rb
@@ -202,7 +204,8 @@ files:
202
204
  homepage: https://github.com/pat/combustion
203
205
  licenses:
204
206
  - MIT
205
- metadata: {}
207
+ metadata:
208
+ rubygems_mfa_required: 'true'
206
209
  post_install_message:
207
210
  rdoc_options: []
208
211
  require_paths:
@@ -218,22 +221,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
221
  - !ruby/object:Gem::Version
219
222
  version: '0'
220
223
  requirements: []
221
- rubygems_version: 3.1.4
224
+ rubygems_version: 3.3.3
222
225
  signing_key:
223
226
  specification_version: 4
224
227
  summary: Elegant Rails Engine Testing
225
228
  test_files:
226
- - spec/spec_helper.rb
229
+ - spec/database_spec.rb
230
+ - spec/dummy/db/migrate/20150717075542_create_dummy_test_table.rb
231
+ - spec/dummy/db/migrate/20150717075543_create_dummy_test_table_in_another_db.rb
232
+ - spec/dummy/lib/engine.rb
233
+ - spec/dummy/spec/internal/app/assets/config/manifest.js
227
234
  - spec/dummy/spec/internal/app/models/model.rb
228
235
  - spec/dummy/spec/internal/app/models/model_in_another_db.rb
229
- - spec/dummy/spec/internal/app/assets/config/manifest.js
230
- - spec/dummy/spec/internal/config/routes.rb
236
+ - spec/dummy/spec/internal/combustion
231
237
  - spec/dummy/spec/internal/config/database.yml
238
+ - spec/dummy/spec/internal/config/routes.rb
232
239
  - spec/dummy/spec/internal/db/schema.rb
233
- - spec/dummy/lib/engine.rb
234
- - spec/dummy/db/migrate/20150717075542_create_dummy_test_table.rb
235
- - spec/dummy/db/migrate/20150717075543_create_dummy_test_table_in_another_db.rb
236
- - spec/database_spec.rb
240
+ - spec/spec_helper.rb
237
241
  - ".rspec"
238
242
  - Appraisals
239
243
  - Gemfile