From 2ea936d05ca9bd7b7a238828a0f558d3bfd075d3 Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Mon, 25 Sep 2023 16:43:48 +0200 Subject: [PATCH 1/3] Relax Ruby version requirement Allow upgrading to Ruby 3. Only define lower compatibility bound from now on to ease future updates REDMINE-19438 --- pageflow-before-after.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pageflow-before-after.gemspec b/pageflow-before-after.gemspec index 7764178..6534f14 100644 --- a/pageflow-before-after.gemspec +++ b/pageflow-before-after.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - spec.required_ruby_version = '~> 2.1' + spec.required_ruby_version = '>= 2.1' spec.add_dependency 'pageflow', ['>= 14', '< 17'] spec.add_dependency 'pageflow-public-i18n', '~> 1.8' From 51a6ab77a5676897c84a971570e4a8d6d8df5dee Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Fri, 29 Sep 2023 09:17:15 +0200 Subject: [PATCH 2/3] Fix Zeitwerk compatibility Add paths to both `autoload_paths` and `eager_load_paths`. `eager_load_paths` is required to have paths covered by `zeitwerk:check`. Ignore root file in lib which does not follow Zeitwerk conventions, but is required for Bundler to be able to require the gem. For Rails < 6, we cannot add `lib` to the `eager_load_paths` since Resque eager loads [1], which then evaluates the engine class a second time. This time `autoload_paths` is already frozen, resulting in an error. REDMINE-19438 [1] https://github.com/resque/resque/blob/v1.27.4/lib/resque/tasks.rb#L45 --- lib/pageflow-before-after.rb | 1 + lib/pageflow/before_after/engine.rb | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/pageflow-before-after.rb b/lib/pageflow-before-after.rb index 3dafe0e..714d3e0 100644 --- a/lib/pageflow-before-after.rb +++ b/lib/pageflow-before-after.rb @@ -1,4 +1,5 @@ require 'pageflow/before_after/engine' +require 'pageflow/before_after/version' module Pageflow module BeforeAfter diff --git a/lib/pageflow/before_after/engine.rb b/lib/pageflow/before_after/engine.rb index e7224de..06d9d8b 100644 --- a/lib/pageflow/before_after/engine.rb +++ b/lib/pageflow/before_after/engine.rb @@ -3,8 +3,23 @@ module BeforeAfter class Engine < Rails::Engine isolate_namespace Pageflow::BeforeAfter - config.autoload_paths << File.join(config.root, 'lib') config.i18n.load_path += Dir[config.root.join('config', 'locales', '**', '*.yml').to_s] + + if Rails.respond_to?(:autoloaders) + lib = root.join('lib') + + config.autoload_paths << lib + config.eager_load_paths << lib + + initializer 'pageflow_before_after.autoloading' do + Rails.autoloaders.main.ignore( + lib.join('pageflow-before-after.rb'), + lib.join('pageflow/before_after/version.rb') + ) + end + else + config.autoload_paths << File.join(config.root, 'lib') + end end end end From 894df14fe266ddb6ca6f2d92377d3a46364c5b99 Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Mon, 2 Oct 2023 06:23:35 +0200 Subject: [PATCH 3/3] Allow running specs against Pageflow edge The reusable workflow now runs specs against experimental Rails versions which require Pageflow to be installed from a git source. REDMINE-19438 --- Gemfile | 11 +++++++++-- pageflow-before-after.gemspec | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index c42a8cd..36347fb 100644 --- a/Gemfile +++ b/Gemfile @@ -3,5 +3,12 @@ source 'https://rubygems.org' # Specify your gem's dependencies in chart.gemspec gemspec -# Speed up dependency resolution -gem 'rails', '~> 5.2.0' +if ENV['PAGEFLOW_DEPENDENCIES'] == 'experimental' + git 'https://github.com/codevise/pageflow', branch: 'edge', glob: '**/*.gemspec' do + gem 'pageflow' + gem 'pageflow-support' + end +else + # Speed up dependency resolution + gem 'rails', '~> 5.2.0' +end diff --git a/pageflow-before-after.gemspec b/pageflow-before-after.gemspec index 6534f14..7c7f524 100644 --- a/pageflow-before-after.gemspec +++ b/pageflow-before-after.gemspec @@ -24,7 +24,12 @@ Gem::Specification.new do |spec| spec.add_dependency 'jquery-ui-rails', '~> 5.0' spec.add_development_dependency 'pageflow-support', ['>= 14', '< 17'] - spec.add_development_dependency 'rspec-rails', '~> 3.0' + + if ENV['PAGEFLOW_DEPENDENCIES'] == 'experimental' + spec.add_development_dependency 'rspec-rails', '~> 6.0' + else + spec.add_development_dependency 'rspec-rails', '~> 3.0' + end # Semantic versioning rake tasks spec.add_development_dependency 'semmy', '~> 1.0'