From 8d7a41f51614261077475f0fc75574ffa2806a60 Mon Sep 17 00:00:00 2001 From: Jury Razumau Date: Tue, 19 Nov 2024 12:47:38 +0100 Subject: [PATCH 1/3] add tests with Rails 7.2 and 8.0 --- .github/workflows/ci.yml | 12 +++++++++--- gemfiles/rails7.2.gemfile | 4 ++++ gemfiles/rails8.0.gemfile | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 gemfiles/rails7.2.gemfile create mode 100644 gemfiles/rails8.0.gemfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 895dc7c..063e7a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,20 +10,26 @@ jobs: fail-fast: false matrix: ruby-version: - - '3.1' - '3.2' - '3.3' gemfile: - rails6.1 - rails7.0 - rails7.1 + - rails7.2 + - rails8.0 - rails_main + include: + - {ruby-version: '3.1', gemfile: rails6.1} + - {ruby-version: '3.1', gemfile: rails7.0} + - {ruby-version: '3.1', gemfile: rails7.1} + - {ruby-version: '3.1', gemfile: rails7.2} env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: - - uses: zendesk/checkout@v4 + - uses: actions/checkout@v4 - name: Set up Ruby - uses: zendesk/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} - run: bundle install diff --git a/gemfiles/rails7.2.gemfile b/gemfiles/rails7.2.gemfile new file mode 100644 index 0000000..7410287 --- /dev/null +++ b/gemfiles/rails7.2.gemfile @@ -0,0 +1,4 @@ +eval_gemfile "common.rb" + +gem "rails", "~> 7.2.0" +gem "actionpack-action_caching" diff --git a/gemfiles/rails8.0.gemfile b/gemfiles/rails8.0.gemfile new file mode 100644 index 0000000..101e19f --- /dev/null +++ b/gemfiles/rails8.0.gemfile @@ -0,0 +1,4 @@ +eval_gemfile "common.rb" + +gem "rails", "~> 8.0.0" +gem "actionpack-action_caching" From 795ea2448c10364b7daf219804e2f49b921e0ca0 Mon Sep 17 00:00:00 2001 From: Jury Razumau Date: Tue, 19 Nov 2024 12:50:39 +0100 Subject: [PATCH 2/3] refresh versions in readme --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7db9acc..8188581 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,6 @@ Include the module `Charcoal::CrossOrigin` in the controller you'd like to allow Included is a CORS pre-flight controller that must be hooked up to the Rails router: -Rails 5: ```ruby match '*path', :to => 'charcoal/cross_origin#preflight', :via => :options ``` @@ -101,9 +100,9 @@ This example adds the `allow_animals` directive that logs "QUACK!" if an applica ## Supported Versions -Ruby >= 2.7 and Rails >= 5.2. +Ruby >= 3.1 and Rails >= 6.1 -[![Build Status](https://github.com/zendesk/charcoal/workflows/CI/badge.svg)](https://github.com/zendesk/charcoal/actions?query=workflow%3ACI) +[![CI status](https://github.com/zendesk/charcoal/actions/workflows/ci.yml/badge.svg)](https://github.com/zendesk/charcoal/actions/workflows/ci.yml) ## Contributing to charcoal From 79381633ddfeb7e9dc49853b901a9359d77da81d Mon Sep 17 00:00:00 2001 From: Jury Razumau Date: Tue, 19 Nov 2024 13:32:08 +0100 Subject: [PATCH 3/3] handle Rails deprecations in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dynamic :controller and :action segments have been deprecated. We replace them with a static list of routes that we use in tests. Another deprecation is “`to_time` will always preserve the receiver timezone rather than system local time in Rails 8.1”. We don’t really care one way or another in this test app, so we opt in for the new behaviour. --- test/helper.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/helper.rb b/test/helper.rb index ec8d678..3201cef 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -17,6 +17,7 @@ class TestApp < Rails::Application config.active_support.deprecation = :stderr + config.active_support.to_time_preserves_timezone = :zone config.active_support.test_order = :random if config.active_support.respond_to?(:test_order=) config.eager_load = false config.secret_key_base = "secret" @@ -36,7 +37,12 @@ class TestEngine < Rails::Engine mount TestEngine => "" match "/test" => "test#test", :via => [:get, :put] match "*path.:format" => "charcoal/cross_origin#preflight", :via => :options - get ":controller/:action" + get "test_controller/test_action", to: "test_controller#test_action" + get "test_cors/test_action", to: "test_cors#test_action" + get "test_cors/test", to: "test_cors#test" + get "test_cors/test_error_action", to: "test_cors#test_error_action" + get "jsonp_controller_tester/test", to: "jsonp_controller_tester#test" + get "charcoal/cross_origin/preflight", to: "charcoal/cross_origin#preflight" end class ActiveSupport::TestCase