From 41e5ced45ff590e831f7008d95386858ea92f0e1 Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Wed, 18 Sep 2024 19:13:30 -0400 Subject: [PATCH] Commit to `ruby@2.6` support Closes [#681][] First, remove `ruby@3.0` syntax including `...` arguments and end-less method definitions. Next, add `ruby@2.6` and `ruby@2.7` to the CI matrix along with `rails@7.1`. [#681]: https://github.com/hotwired/turbo-rails/issues/681 --- .github/workflows/ci.yml | 9 +++++++-- Gemfile | 2 +- app/models/concerns/turbo/broadcastable.rb | 2 +- test/streams/broadcastable_test.rb | 10 ++++++---- test/streams/streams_helper_test.rb | 14 ++++++++++---- test/test_helper.rb | 4 ++-- 6 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52846f1f..f6f69b12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,13 +5,17 @@ jobs: strategy: fail-fast: false matrix: - rails: [ "6.1", "7.0", "7.1" ] - ruby: [ "3.0", "3.1", "3.2", "3.3" ] + rails: [ "6.1", "7.0", "7.1", "7.2" ] + ruby: [ "2.7", "3.0", "3.1", "3.2", "3.3" ] allow-fail: [ false ] include: + - { ruby: "2.6", rails: "6.1" } - { ruby: "3.3", rails: "main", allow-fail: true } - { ruby: "3.2", rails: "main", allow-fail: true } - { ruby: "head", rails: "main", allow-fail: true } + exclude: + - { ruby: "2.7", rails: "7.2" } + - { ruby: "3.0", rails: "7.2" } env: FERRUM_PROCESS_TIMEOUT: 25 @@ -33,6 +37,7 @@ jobs: - name: Run Bug Template Tests run: ruby bug_report_template.rb || ruby bug_report_template.rb + continue-on-error: ${{ startsWith(matrix.ruby, '2') || false }} - name: Run tests id: test diff --git a/Gemfile b/Gemfile index fe6844ae..dd8f544c 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' gemspec -rails_version = ENV.fetch("RAILS_VERSION", "7.1") +rails_version = ENV.fetch("RAILS_VERSION", "7.2") if rails_version == "main" rails_constraint = { github: "rails/rails" } diff --git a/app/models/concerns/turbo/broadcastable.rb b/app/models/concerns/turbo/broadcastable.rb index b39c186e..0afe55f9 100644 --- a/app/models/concerns/turbo/broadcastable.rb +++ b/app/models/concerns/turbo/broadcastable.rb @@ -508,7 +508,7 @@ def broadcast_target_default self.class.broadcast_target_default end - def extract_options_and_add_target(rendering = {}, target: broadcast_target_default) + def extract_options_and_add_target(rendering = {}, target: broadcast_target_default, targets: nil) broadcast_rendering_with_defaults(rendering).tap do |options| options[:target] = target if !options.key?(:target) && !options.key?(:targets) end diff --git a/test/streams/broadcastable_test.rb b/test/streams/broadcastable_test.rb index dbbb1d78..a5fedc91 100644 --- a/test/streams/broadcastable_test.rb +++ b/test/streams/broadcastable_test.rb @@ -9,10 +9,12 @@ class Turbo::BroadcastableTest < ActionCable::Channel::TestCase test "broadcasting ignores blank streamables" do ActionCable.server.stub :broadcast, proc { flunk "expected no broadcasts" } do - @message.broadcast_remove_to nil - @message.broadcast_remove_to [nil] - @message.broadcast_remove_to "" - @message.broadcast_remove_to [""] + assert_no_broadcasts @message.to_gid_param do + @message.broadcast_remove_to nil + @message.broadcast_remove_to [nil] + @message.broadcast_remove_to "" + @message.broadcast_remove_to [""] + end end end diff --git a/test/streams/streams_helper_test.rb b/test/streams/streams_helper_test.rb index be9bea9f..45d66429 100644 --- a/test/streams/streams_helper_test.rb +++ b/test/streams/streams_helper_test.rb @@ -4,11 +4,17 @@ class TestChannel < ApplicationCable::Channel; end class Turbo::StreamsHelperTest < ActionView::TestCase class Component - extend ActiveModel::Naming + include ActiveModel::Model - def initialize(id:, content:) = (@id, @content = id, content) - def render_in(...) = @content - def to_key = [@id] + attr_accessor :id, :content + + def render_in(view_context) + content + end + + def to_key + [id] + end end attr_accessor :formats diff --git a/test/test_helper.rb b/test/test_helper.rb index bbe0f583..1c54616f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -8,8 +8,8 @@ ActionCable.server.config.logger = Logger.new(STDOUT) if ENV["VERBOSE"] module ActionViewTestCaseExtensions - def render(...) - ApplicationController.renderer.render(...) + def render(*args, &block) + ApplicationController.renderer.render(*args, &block) end end