combustion 1.3.5 → 1.3.6
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 +4 -2
- data/Gemfile +3 -0
- data/README.md +2 -2
- data/lib/combustion/application.rb +6 -4
- data/lib/combustion/configurations/active_record.rb +1 -1
- data/lib/combustion/database/migrate.rb +4 -2
- data/lib/combustion/database/reset.rb +1 -1
- data/lib/combustion/version_gate.rb +35 -0
- data/lib/combustion.rb +10 -8
- data/spec/database_spec.rb +4 -4
- data/spec/dummy/spec/internal/combustion +0 -0
- data/spec/dummy/spec/internal/config/database.yml +5 -1
- data/spec/spec_helper.rb +1 -1
- metadata +13 -10
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8736ae93f4eac4f43a47ebdd063f4ad227f307dd973536ab710a5584ed29976d
         | 
| 4 | 
            +
              data.tar.gz: 880e055549466b9c7203a2f34fd437addc3b580b0a100ca4b5aa2cef7ba4bce8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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. | 
| 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
    
    
    
        data/README.md
    CHANGED
    
    | @@ -158,7 +158,7 @@ Parameters defined in, for instance, `spec/internals/config/environments/test.rb | |
| 158 158 |  | 
| 159 159 | 
             
            ### Using other Rails-focused libraries
         | 
| 160 160 |  | 
| 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  | 
| 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.
         | 
| 162 162 |  | 
| 163 163 | 
             
            ### Environment and Logging
         | 
| 164 164 |  | 
| @@ -187,7 +187,7 @@ end | |
| 187 187 |  | 
| 188 188 | 
             
            ## Compatibility
         | 
| 189 189 |  | 
| 190 | 
            -
            The current test matrix covers MRI 2. | 
| 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.
         | 
| 191 191 |  | 
| 192 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.
         | 
| 193 193 |  | 
| @@ -13,16 +13,18 @@ module Combustion | |
| 13 13 | 
             
                  Combustion::Configurations::ActiveStorage
         | 
| 14 14 | 
             
                ].freeze
         | 
| 15 15 |  | 
| 16 | 
            -
                 | 
| 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  | 
| 24 | 
            -
                config.whiny_nils      = true             if  | 
| 25 | 
            -
                 | 
| 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
         | 
| @@ -4,7 +4,7 @@ class Combustion::Configurations::ActiveRecord | |
| 4 4 | 
             
              def self.call(config)
         | 
| 5 5 | 
             
                return unless defined?(ActiveRecord::Railtie)
         | 
| 6 6 |  | 
| 7 | 
            -
                if  | 
| 7 | 
            +
                if Combustion::VersionGate.call("activerecord", "~> 7.0.0")
         | 
| 8 8 | 
             
                  config.active_record.legacy_connection_handling = false
         | 
| 9 9 | 
             
                end
         | 
| 10 10 |  | 
| @@ -6,9 +6,11 @@ class Combustion::Database::Migrate | |
| 6 6 | 
             
              end
         | 
| 7 7 |  | 
| 8 8 | 
             
              def call
         | 
| 9 | 
            -
                 | 
| 9 | 
            +
                ar_gate = Combustion::VersionGate.new("activerecord")
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                if ar_gate.call(">= 5.2")
         | 
| 10 12 | 
             
                  migration_context.migrate
         | 
| 11 | 
            -
                elsif  | 
| 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  | 
| 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
         | 
| @@ -28,14 +30,14 @@ module Combustion | |
| 28 30 |  | 
| 29 31 | 
             
              AVAILABLE_MODULES = begin
         | 
| 30 32 | 
             
                keys = MODULES.keys
         | 
| 31 | 
            -
                 | 
| 32 | 
            -
             | 
| 33 | 
            -
                keys.delete(:sprockets) unless (3.1 | 
| 34 | 
            -
                keys.delete(:active_job) unless  | 
| 35 | 
            -
                keys.delete(:action_cable) unless  | 
| 36 | 
            -
                keys.delete(:active_storage) unless  | 
| 37 | 
            -
                keys.delete(:action_text) unless  | 
| 38 | 
            -
                keys.delete(:action_mailbox) unless  | 
| 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")
         | 
| 39 41 |  | 
| 40 42 | 
             
                keys
         | 
| 41 43 | 
             
              end.freeze
         | 
    
        data/spec/database_spec.rb
    CHANGED
    
    | @@ -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  | 
| 18 | 
            -
                  expect(Model.connection_db_config.database).to match(/ | 
| 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(/ | 
| 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  | 
| 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:  | 
| 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
    
    
    
        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. | 
| 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:  | 
| 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
         | 
| @@ -219,22 +221,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 219 221 | 
             
                - !ruby/object:Gem::Version
         | 
| 220 222 | 
             
                  version: '0'
         | 
| 221 223 | 
             
            requirements: []
         | 
| 222 | 
            -
            rubygems_version: 3. | 
| 224 | 
            +
            rubygems_version: 3.3.3
         | 
| 223 225 | 
             
            signing_key:
         | 
| 224 226 | 
             
            specification_version: 4
         | 
| 225 227 | 
             
            summary: Elegant Rails Engine Testing
         | 
| 226 228 | 
             
            test_files:
         | 
| 227 | 
            -
            - spec/ | 
| 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
         | 
| 228 234 | 
             
            - spec/dummy/spec/internal/app/models/model.rb
         | 
| 229 235 | 
             
            - spec/dummy/spec/internal/app/models/model_in_another_db.rb
         | 
| 230 | 
            -
            - spec/dummy/spec/internal/ | 
| 231 | 
            -
            - spec/dummy/spec/internal/config/routes.rb
         | 
| 236 | 
            +
            - spec/dummy/spec/internal/combustion
         | 
| 232 237 | 
             
            - spec/dummy/spec/internal/config/database.yml
         | 
| 238 | 
            +
            - spec/dummy/spec/internal/config/routes.rb
         | 
| 233 239 | 
             
            - spec/dummy/spec/internal/db/schema.rb
         | 
| 234 | 
            -
            - spec/ | 
| 235 | 
            -
            - spec/dummy/db/migrate/20150717075542_create_dummy_test_table.rb
         | 
| 236 | 
            -
            - spec/dummy/db/migrate/20150717075543_create_dummy_test_table_in_another_db.rb
         | 
| 237 | 
            -
            - spec/database_spec.rb
         | 
| 240 | 
            +
            - spec/spec_helper.rb
         | 
| 238 241 | 
             
            - ".rspec"
         | 
| 239 242 | 
             
            - Appraisals
         | 
| 240 243 | 
             
            - Gemfile
         |