Skip to content

Commit 551bf1d

Browse files
committed
Commit to [email protected] support
Closes [#681][] First, remove `[email protected]` syntax including `...` arguments and end-less method definitions. Next, add `[email protected]` and `[email protected]` to the CI matrix along with `[email protected]`. [#681]: #681
1 parent 59e1f48 commit 551bf1d

File tree

10 files changed

+53
-27
lines changed

10 files changed

+53
-27
lines changed

.github/workflows/ci.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ jobs:
55
strategy:
66
fail-fast: false
77
matrix:
8-
rails: [ "6.1", "7.0", "7.1" ]
9-
ruby: [ "3.0", "3.1", "3.2", "3.3" ]
8+
rails: [ "6.1", "7.0", "7.1", "7.2" ]
9+
ruby: [ "2.7", "3.0", "3.1", "3.2", "3.3" ]
1010
allow-fail: [ false ]
1111
include:
12+
- { ruby: "2.6", rails: "6.1" }
1213
- { ruby: "3.3", rails: "main", allow-fail: true }
1314
- { ruby: "3.2", rails: "main", allow-fail: true }
1415
- { ruby: "head", rails: "main", allow-fail: true }
16+
exclude:
17+
- { ruby: "2.7", rails: "7.2" }
18+
- { ruby: "3.0", rails: "7.2" }
1519

1620
env:
1721
FERRUM_PROCESS_TIMEOUT: 25
@@ -33,6 +37,7 @@ jobs:
3337

3438
- name: Run Bug Template Tests
3539
run: ruby bug_report_template.rb || ruby bug_report_template.rb
40+
continue-on-error: ${{ startsWith(matrix.ruby, '2') || false }}
3641

3742
- name: Run tests
3843
id: test

Gemfile

+15-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
22

33
gemspec
44

5-
rails_version = ENV.fetch("RAILS_VERSION", "7.1")
5+
rails_version = ENV.fetch("RAILS_VERSION", "7.2")
66

77
if rails_version == "main"
88
rails_constraint = { github: "rails/rails" }
@@ -15,16 +15,26 @@ gem "sprockets-rails"
1515

1616
gem 'rake'
1717
gem 'byebug'
18-
gem 'puma'
19-
gem 'rack'
18+
19+
if RUBY_VERSION < "3"
20+
gem "rack", "< 3"
21+
gem "puma", "< 6"
22+
else
23+
gem "rack"
24+
gem "puma"
25+
end
2026

2127
group :development, :test do
22-
gem 'importmap-rails'
28+
if rails_version == "6.1"
29+
gem "importmap-rails", "0.6.1"
30+
else
31+
gem "importmap-rails"
32+
end
2333
end
2434

2535
group :test do
2636
gem 'capybara'
2737
gem 'rexml'
2838
gem 'cuprite', '~> 0.9', require: 'capybara/cuprite'
29-
gem 'sqlite3', '~> 1.4'
39+
gem 'sqlite3', '1.5'
3040
end

app/helpers/turbo/streams/action_helper.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ module Turbo::Streams::ActionHelper
2222
# message = Message.find(1)
2323
# turbo_stream_action_tag "remove", target: [message, :special]
2424
# # => <turbo-stream action="remove" target="special_message_1"></turbo-stream>
25-
def turbo_stream_action_tag(action, target: nil, targets: nil, template: nil, **attributes)
25+
def turbo_stream_action_tag(action, attributes = {})
26+
target = attributes.delete(:target)
27+
targets = attributes.delete(:targets)
28+
template = attributes.delete(:template)
2629
template = action.to_sym.in?(%i[ remove refresh ]) ? "" : tag.template(template.to_s.html_safe)
2730

2831
if target = convert_to_turbo_stream_dom_id(target)
@@ -39,7 +42,7 @@ def turbo_stream_action_tag(action, target: nil, targets: nil, template: nil, **
3942
# turbo_stream_refresh_tag
4043
# # => <turbo-stream action="refresh"></turbo-stream>
4144
def turbo_stream_refresh_tag(request_id: Turbo.current_request_id, **attributes)
42-
turbo_stream_action_tag(:refresh, **{ "request-id": request_id }.compact, **attributes)
45+
turbo_stream_action_tag(:refresh, attributes.with_defaults({ "request-id": request_id }.compact))
4346
end
4447

4548
private

app/models/concerns/turbo/broadcastable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def broadcast_target_default
508508
self.class.broadcast_target_default
509509
end
510510

511-
def extract_options_and_add_target(rendering = {}, target: broadcast_target_default)
511+
def extract_options_and_add_target(rendering, target: broadcast_target_default)
512512
broadcast_rendering_with_defaults(rendering).tap do |options|
513513
options[:target] = target if !options.key?(:target) && !options.key?(:targets)
514514
end

app/models/turbo/streams/tag_builder.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ def prepend_all(targets, content = nil, **rendering, &block)
240240
#
241241
# turbo_stream.refresh request_id: "abc123"
242242
# # => <turbo-stream action="refresh" request-id="abc123"></turbo-stream>
243-
def refresh(...)
244-
turbo_stream_refresh_tag(...)
243+
def refresh(**options)
244+
turbo_stream_refresh_tag(**options)
245245
end
246246

247247
# Send an action of the type <tt>name</tt> to <tt>target</tt>. Options described in the concrete methods.

lib/turbo/engine.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class TurboStreamEncoder < IdentityEncoder
164164
ActiveSupport.on_load(:action_dispatch_system_test_case) do
165165
app.config.turbo.test_connect_after_actions.map do |method|
166166
class_eval <<~RUBY, __FILE__, __LINE__ + 1
167-
def #{method}(...) # def visit(...)
167+
def #{method}(*args, &block) # def visit(*args, &block)
168168
super.tap { connect_turbo_cable_stream_sources } # super.tap { connect_turbo_cable_stream_sources }
169169
end # end
170170
RUBY

lib/turbo/system_test_helper.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def connect_turbo_cable_stream_sources(**options, &block)
5151
#
5252
# In addition to the filters listed above, accepts any valid Capybara global
5353
# filter option.
54-
def assert_turbo_cable_stream_source(...)
55-
assert_selector(:turbo_cable_stream_source, ...)
54+
def assert_turbo_cable_stream_source(*args, &block)
55+
assert_selector(:turbo_cable_stream_source, *args, &block)
5656
end
5757

5858
# Asserts that a `<turbo-cable-stream-source>` element is absent from the
@@ -75,8 +75,8 @@ def assert_turbo_cable_stream_source(...)
7575
#
7676
# In addition to the filters listed above, accepts any valid Capybara global
7777
# filter option.
78-
def assert_no_turbo_cable_stream_source(...)
79-
assert_no_selector(:turbo_cable_stream_source, ...)
78+
def assert_no_turbo_cable_stream_source(*args, &block)
79+
assert_no_selector(:turbo_cable_stream_source, *args, &block)
8080
end
8181

8282
Capybara.add_selector :turbo_cable_stream_source do

test/streams/broadcastable_test.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ def to_partial_path
1515

1616
test "broadcasting ignores blank streamables" do
1717
ActionCable.server.stub :broadcast, proc { flunk "expected no broadcasts" } do
18-
@message.broadcast_remove_to nil
19-
@message.broadcast_remove_to [nil]
20-
@message.broadcast_remove_to ""
21-
@message.broadcast_remove_to [""]
18+
assert_no_broadcasts @message.to_gid_param do
19+
@message.broadcast_remove_to nil
20+
@message.broadcast_remove_to [nil]
21+
@message.broadcast_remove_to ""
22+
@message.broadcast_remove_to [""]
23+
end
2224
end
2325
end
2426

test/streams/streams_helper_test.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ class TestChannel < ApplicationCable::Channel; end
44

55
class Turbo::StreamsHelperTest < ActionView::TestCase
66
class Component
7-
extend ActiveModel::Naming
7+
include ActiveModel::Model
88

9-
def initialize(id:, content:) = (@id, @content = id, content)
10-
def render_in(...) = @content
11-
def to_key = [@id]
9+
attr_accessor :id, :content
10+
11+
def render_in(view_context)
12+
content
13+
end
14+
15+
def to_key
16+
[id]
17+
end
1218
end
1319

1420
attr_accessor :formats

test/test_helper.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
ActionCable.server.config.logger = Logger.new(STDOUT) if ENV["VERBOSE"]
99

1010
module ActionViewTestCaseExtensions
11-
def render(...)
12-
ApplicationController.renderer.render(...)
11+
def render(*args, &block)
12+
ApplicationController.renderer.render(*args, &block)
1313
end
1414
end
1515

0 commit comments

Comments
 (0)