diff --git a/.github/workflows/master_and_pr.yml b/.github/workflows/master_and_pr.yml index d3e4b92..d792633 100644 --- a/.github/workflows/master_and_pr.yml +++ b/.github/workflows/master_and_pr.yml @@ -10,45 +10,21 @@ jobs: strategy: matrix: rails_version: - - "5.0" - - "5.1" - - "5.2" - - "6.0" - "6.1" + - "7.0" + - "7.1" ruby_version: - - "2.7" - "3.1" - autoloader: - - "zeitwerk" - - "classic" + - "3.2" + - "3.3" eager_load: - "true" - "false" - exclude: - - rails_version: "5.0" - ruby_version: "3.1" - - rails_version: "5.1" - ruby_version: "3.1" - - rails_version: "5.2" - ruby_version: "3.1" - - rails_version: "5.0" - autoloader: "zeitwerk" - - rails_version: "5.1" - autoloader: "zeitwerk" - - rails_version: "5.2" - autoloader: "zeitwerk" - - rails_version: "5.0" - autoloader: "classic" - - rails_version: "5.1" - autoloader: "classic" - - rails_version: "5.2" - autoloader: "classic" - name: Test on Rails ${{ matrix.rails_version }} & Ruby ${{ matrix.ruby_version }} & Autoloader ${{ matrix.autoloader }} & EagerLoad ${{ matrix.eager_load }} + name: Test on Rails ${{ matrix.rails_version }} & Ruby ${{ matrix.ruby_version }} & EagerLoad ${{ matrix.eager_load }} env: BUNDLE_GEMFILE: gemfiles/Gemfile_rails_${{ matrix.rails_version }}.rb CI: true EAGER_LOAD: ${{ matrix.eager_load }} - AUTOLOADER : ${{ matrix.autoloader }} steps: - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 @@ -58,7 +34,7 @@ jobs: - name: rspec run: bundle exec rspec - name: Coveralls - if: matrix.rails_version == '6.1' && matrix.ruby_version == '3.1' + if: matrix.rails_version == '7.1' && matrix.ruby_version == '3.3' uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 80ef836..a835fb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ ## Unreleased +* Support Rails 6,1. 7.0, 7.1. +* Drop support for Raiils below 6.0 +* Drop support for Ruby 2 +* Drop support for classic loader +* The functionality to extend the view_paths has been discontinued. ## 2.3.0 * Support Rails 5.0, 5.1, 5,2, 6.0, 6,1. diff --git a/chanko.gemspec b/chanko.gemspec index b8b822b..260b6f7 100644 --- a/chanko.gemspec +++ b/chanko.gemspec @@ -14,9 +14,9 @@ Gem::Specification.new do |gem| gem.files = `git ls-files`.split($/) gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] - gem.required_ruby_version = '>= 2.6.0' + gem.required_ruby_version = '>= 3.0.0' - gem.add_dependency "rails", ">= 5.0.0" + gem.add_dependency "rails", ">= 6.1.0" gem.add_development_dependency "byebug" gem.add_development_dependency "coffee-rails", ">= 3.0.10" gem.add_development_dependency "jquery-rails" @@ -27,7 +27,7 @@ Gem::Specification.new do |gem| gem.add_development_dependency "simplecov" gem.add_development_dependency 'simplecov-lcov' gem.add_development_dependency "slim" - gem.add_development_dependency "sqlite3" + gem.add_development_dependency "sqlite3", ">= 1.4" gem.add_development_dependency "thin" gem.add_development_dependency "uglifier" end diff --git a/gemfiles/Gemfile_rails_5.0.rb b/gemfiles/Gemfile_rails_5.0.rb deleted file mode 100644 index 4c8bb7e..0000000 --- a/gemfiles/Gemfile_rails_5.0.rb +++ /dev/null @@ -1,6 +0,0 @@ -source "https://rubygems.org" - -gemspec path: '..' - -gem 'rails', '~> 5.0.0' -gem 'sqlite3', '~> 1.3.6' diff --git a/gemfiles/Gemfile_rails_5.1.rb b/gemfiles/Gemfile_rails_5.1.rb deleted file mode 100644 index 333f2eb..0000000 --- a/gemfiles/Gemfile_rails_5.1.rb +++ /dev/null @@ -1,6 +0,0 @@ -source "https://rubygems.org" - -gemspec path: '..' - -gem 'rails', '~> 5.1.0' -gem 'sqlite3', '~> 1.3.6' diff --git a/gemfiles/Gemfile_rails_5.2.rb b/gemfiles/Gemfile_rails_5.2.rb deleted file mode 100644 index a1fe02e..0000000 --- a/gemfiles/Gemfile_rails_5.2.rb +++ /dev/null @@ -1,6 +0,0 @@ -source "https://rubygems.org" - -gemspec path: '..' - -gem 'rails', '~> 5.2.0' -gem 'sqlite3', '~> 1.3.6' diff --git a/gemfiles/Gemfile_rails_6.0.rb b/gemfiles/Gemfile_rails_6.0.rb deleted file mode 100644 index 8da51e2..0000000 --- a/gemfiles/Gemfile_rails_6.0.rb +++ /dev/null @@ -1,8 +0,0 @@ -source "https://rubygems.org" - -gemspec path: '..' - -gem 'rails', '~> 6.0.0' -gem 'net-smtp' -gem 'net-pop' -gem 'net-imap' diff --git a/gemfiles/Gemfile_rails_6.1.rb b/gemfiles/Gemfile_rails_6.1.rb index ae45666..e33d7b1 100644 --- a/gemfiles/Gemfile_rails_6.1.rb +++ b/gemfiles/Gemfile_rails_6.1.rb @@ -1,8 +1,6 @@ -source "https://rubygems.org" +source 'https://rubygems.org' gemspec path: '..' gem 'rails', '~> 6.1.0' -gem 'net-smtp' -gem 'net-pop' -gem 'net-imap' +gem 'sqlite3', '~> 1.4' diff --git a/gemfiles/Gemfile_rails_7.0.rb b/gemfiles/Gemfile_rails_7.0.rb new file mode 100644 index 0000000..2ebe1e4 --- /dev/null +++ b/gemfiles/Gemfile_rails_7.0.rb @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gemspec path: '..' + +gem 'rails', '~> 7.0.0' +gem 'sqlite3', '~> 1.4' diff --git a/gemfiles/Gemfile_rails_7.1.rb b/gemfiles/Gemfile_rails_7.1.rb new file mode 100644 index 0000000..7fdd267 --- /dev/null +++ b/gemfiles/Gemfile_rails_7.1.rb @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +gemspec path: '..' + +gem 'rails', '~> 7.1.0' +gem 'sqlite3', '~> 1.4' diff --git a/lib/chanko/railtie.rb b/lib/chanko/railtie.rb index 2ce3965..c5c804f 100644 --- a/lib/chanko/railtie.rb +++ b/lib/chanko/railtie.rb @@ -21,14 +21,6 @@ class Railtie < Rails::Railtie Chanko::Loader.prepare_eager_load(mode: :zeitwerk) end - initializer("chanko.classic.prepare_eager_load", after: :load_environment_config) do |app| - # Rails5 doens't load environments/*.rb files before :set_autoload_paths. - # In other words, at this stage, config.eager_load cannot be determined to be true or false. - # But classic loader does not freeze paths on :set_autoload_paths. - # After all, It's ok if it is executed after :set_autoload_paths on Rails5 and Rails6(classic). - Chanko::Loader.prepare_eager_load(mode: :classic) - end - initializer("chanko.eager_load_units", before: :eager_load!) do |app| # This is why we need handmade eager-loading # https://github.com/cookpad/chanko/pull/38 diff --git a/spec/chanko/function_spec.rb b/spec/chanko/function_spec.rb index 5b39adf..ae4d9a9 100644 --- a/spec/chanko/function_spec.rb +++ b/spec/chanko/function_spec.rb @@ -6,20 +6,7 @@ module Chanko Loader.load(:example_unit) end - def rails5_action_view_instance - klass = Class.new(ActionView::Base) do - def current_unit - units.last - end - - def units - @units ||= [] - end - end - klass.new - end - - def rails6_action_view_instance + def action_view_instance klass = Class.new(ActionView::Base.with_empty_template_cache) do def current_unit units.last @@ -33,12 +20,7 @@ def units end let(:context) do - case Rails::VERSION::MAJOR - when 5 - rails5_action_view_instance - when 6 - rails6_action_view_instance - end + action_view_instance end let(:options) do diff --git a/spec/chanko/test_spec.rb b/spec/chanko/test_spec.rb index 5f63c95..bdfc03c 100644 --- a/spec/chanko/test_spec.rb +++ b/spec/chanko/test_spec.rb @@ -3,24 +3,11 @@ module Chanko describe Test do - def rails5_action_view_instance - Class.new(ActionView::Base).new - end - - def rails6_action_view_instance + let(:view) do klass = Class.new(ActionView::Base.with_empty_template_cache) klass.with_view_paths(nil, {}, nil) end - let(:view) do - case Rails::VERSION::MAJOR - when 5 - rails5_action_view_instance - when 6 - rails6_action_view_instance - end - end - describe "#enable_unit" do it "forces to enable specified unit" do enable_unit(:inactive_unit) diff --git a/spec/dummy/config/application.rb b/spec/dummy/config/application.rb index 91f1425..c2b74b7 100644 --- a/spec/dummy/config/application.rb +++ b/spec/dummy/config/application.rb @@ -47,20 +47,15 @@ class Application < Rails::Application # config.active_record.schema_format = :sql # Version of your assets, change this if you want to expire all your assets - config.assets.version = '1.0' - config.assets.quiet = true if ::Rails::VERSION::MAJOR >= 5 - if Rails::VERSION::MAJOR >= 6 - if ENV['AUTOLOADER'] == 'zeitwerk' - Chanko::Test.logger.info("Autoloader: zeitwerk") - config.autoloader = :zeitwerk - else - Chanko::Test.logger.info("Autoloader: classic") - config.autoloader = :classic - end + + # for Rails 6.1 + if config.respond_to?("assets") + config.assets.version = '1.0' + config.assets.quiet = true end + + config.autoloader = :zeitwerk end end -if Rails::VERSION::MAJOR >= 6 && Rails.autoloaders.zeitwerk_enabled? - Rails.autoloaders.main.collapse(Rails.root.join('app', 'units', '*')) -end +Rails.autoloaders.main.collapse(Rails.root.join('app', 'units', '*'))