turbo-rails 0.5.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +113 -18
- data/Rakefile +19 -2
- data/app/assets/javascripts/turbo.js +4143 -1431
- data/app/assets/javascripts/turbo.min.js +29 -0
- data/app/assets/javascripts/turbo.min.js.map +1 -0
- data/app/channels/turbo/streams/broadcasts.rb +58 -22
- data/app/channels/turbo/streams/stream_name.rb +7 -0
- data/app/channels/turbo/streams_channel.rb +30 -2
- data/app/controllers/concerns/turbo/request_id_tracking.rb +12 -0
- data/app/controllers/turbo/frames/frame_request.rb +22 -8
- data/app/controllers/turbo/native/navigation.rb +19 -9
- data/app/helpers/turbo/drive_helper.rb +75 -3
- data/app/helpers/turbo/frames_helper.rb +21 -2
- data/app/helpers/turbo/includes_helper.rb +2 -0
- data/app/helpers/turbo/streams/action_helper.rb +34 -9
- data/app/helpers/turbo/streams_helper.rb +20 -7
- data/app/javascript/turbo/cable.js +6 -3
- data/app/javascript/turbo/cable_stream_source_element.js +19 -3
- data/app/javascript/turbo/fetch_requests.js +59 -0
- data/app/javascript/turbo/index.js +6 -0
- data/app/javascript/turbo/snakeize.js +31 -0
- data/app/jobs/turbo/streams/action_broadcast_job.rb +4 -2
- data/app/jobs/turbo/streams/broadcast_job.rb +2 -0
- data/app/jobs/turbo/streams/broadcast_stream_job.rb +7 -0
- data/app/models/concerns/turbo/broadcastable.rb +246 -38
- data/app/models/turbo/debouncer.rb +24 -0
- data/app/models/turbo/streams/tag_builder.rb +163 -21
- data/app/models/turbo/thread_debouncer.rb +28 -0
- data/app/views/layouts/turbo_rails/frame.html.erb +8 -0
- data/config/routes.rb +1 -2
- data/lib/install/turbo_needs_redis.rb +20 -0
- data/lib/install/turbo_with_bun.rb +9 -0
- data/lib/install/turbo_with_importmap.rb +5 -0
- data/lib/install/turbo_with_node.rb +9 -0
- data/lib/tasks/turbo_tasks.rake +50 -8
- data/lib/turbo/broadcastable/test_helper.rb +172 -0
- data/lib/turbo/engine.rb +40 -6
- data/lib/turbo/test_assertions/integration_test_assertions.rb +76 -0
- data/lib/turbo/test_assertions.rb +69 -8
- data/lib/turbo/version.rb +1 -1
- data/lib/turbo-rails.rb +12 -0
- metadata +48 -173
- data/.github/workflows/ci.yml +0 -30
- data/.gitignore +0 -2
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -147
- data/lib/install/turbo_with_asset_pipeline.rb +0 -20
- data/lib/install/turbo_with_webpacker.rb +0 -24
- data/package.json +0 -47
- data/rollup.config.js +0 -23
- data/test/drive/drive_helper_test.rb +0 -8
- data/test/dummy/.babelrc +0 -18
- data/test/dummy/.gitignore +0 -3
- data/test/dummy/.postcssrc.yml +0 -3
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/config/manifest.js +0 -2
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/assets/stylesheets/scaffold.css +0 -80
- data/test/dummy/app/channels/application_cable/channel.rb +0 -4
- data/test/dummy/app/channels/application_cable/connection.rb +0 -4
- data/test/dummy/app/controllers/application_controller.rb +0 -2
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/controllers/messages_controller.rb +0 -12
- data/test/dummy/app/controllers/trays_controller.rb +0 -17
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/javascript/packs/application.js +0 -0
- data/test/dummy/app/jobs/application_job.rb +0 -2
- data/test/dummy/app/mailboxes/application_mailbox.rb +0 -2
- data/test/dummy/app/mailboxes/messages_mailbox.rb +0 -4
- data/test/dummy/app/mailers/application_mailer.rb +0 -4
- data/test/dummy/app/models/application_record.rb +0 -3
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/models/message.rb +0 -29
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/test/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/test/dummy/app/views/messages/_message.html.erb +0 -1
- data/test/dummy/app/views/messages/_message.turbo_stream.erb +0 -1
- data/test/dummy/app/views/messages/show.turbo_stream.erb +0 -9
- data/test/dummy/app/views/trays/index.html.erb +0 -3
- data/test/dummy/app/views/trays/show.html.erb +0 -3
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -36
- data/test/dummy/bin/update +0 -31
- data/test/dummy/bin/yarn +0 -11
- data/test/dummy/config/application.rb +0 -22
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/cable.yml +0 -10
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -34
- data/test/dummy/config/environments/production.rb +0 -96
- data/test/dummy/config/environments/test.rb +0 -38
- data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/test/dummy/config/initializers/assets.rb +0 -14
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/content_security_policy.rb +0 -22
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -33
- data/test/dummy/config/puma.rb +0 -34
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/config/spring.rb +0 -6
- data/test/dummy/config/webpack/development.js +0 -3
- data/test/dummy/config/webpack/environment.js +0 -3
- data/test/dummy/config/webpack/production.js +0 -3
- data/test/dummy/config/webpack/test.js +0 -3
- data/test/dummy/config/webpacker.yml +0 -65
- data/test/dummy/config.ru +0 -5
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/frames/frame_request_controller_test.rb +0 -21
- data/test/frames/frames_helper_test.rb +0 -21
- data/test/native/navigation_controller_test.rb +0 -42
- data/test/streams/broadcastable_test.rb +0 -80
- data/test/streams/streams_channel_test.rb +0 -105
- data/test/streams/streams_controller_test.rb +0 -29
- data/test/turbo_test.rb +0 -10
- data/turbo-rails.gemspec +0 -17
- data/yarn.lock +0 -283
data/test/dummy/public/422.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
.rails-default-error-page {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
.rails-default-error-page div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
.rails-default-error-page div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
.rails-default-error-page h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
.rails-default-error-page div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body class="rails-default-error-page">
|
58
|
-
<!-- This file lives in public/422.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The change you wanted was rejected.</h1>
|
62
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/test/dummy/public/500.html
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
.rails-default-error-page {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
.rails-default-error-page div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
.rails-default-error-page div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
.rails-default-error-page h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
.rails-default-error-page div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body class="rails-default-error-page">
|
58
|
-
<!-- This file lives in public/500.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>We're sorry, but something went wrong.</h1>
|
62
|
-
</div>
|
63
|
-
<p>If you are the application owner check the logs for more information.</p>
|
64
|
-
</div>
|
65
|
-
</body>
|
66
|
-
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "turbo_test"
|
2
|
-
|
3
|
-
class Turbo::FrameRequestControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
test "frame requests are rendered without a layout" do
|
5
|
-
get tray_path(id: 1)
|
6
|
-
assert_select "title", count: 1
|
7
|
-
|
8
|
-
get tray_path(id: 1), headers: { "Turbo-Frame" => "true" }
|
9
|
-
assert_select "title", count: 0
|
10
|
-
end
|
11
|
-
|
12
|
-
test "frame requests get a unique etag" do
|
13
|
-
get tray_path(id: 1)
|
14
|
-
etag_without_frame = @response.headers["ETag"]
|
15
|
-
|
16
|
-
get tray_path(id: 1), headers: { "Turbo-Frame" => "true" }
|
17
|
-
etag_with_frame = @response.headers["ETag"]
|
18
|
-
|
19
|
-
assert_not_equal etag_with_frame, etag_without_frame
|
20
|
-
end
|
21
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "turbo_test"
|
2
|
-
|
3
|
-
class Turbo::FramesHelperTest < ActionView::TestCase
|
4
|
-
test "frame with src" do
|
5
|
-
assert_dom_equal %(<turbo-frame src="/trays/1" id="tray"></turbo-frame>), turbo_frame_tag("tray", src: "/trays/1")
|
6
|
-
end
|
7
|
-
|
8
|
-
test "frame with src and target" do
|
9
|
-
assert_dom_equal %(<turbo-frame src="/trays/1" id="tray" target="_top"></turbo-frame>), turbo_frame_tag("tray", src: "/trays/1", target: "_top")
|
10
|
-
end
|
11
|
-
|
12
|
-
test "frame with model argument" do
|
13
|
-
record = Message.new(record_id: "1", content: "ignored")
|
14
|
-
|
15
|
-
assert_dom_equal %(<turbo-frame id="message_1"></turbo-frame>), turbo_frame_tag(record)
|
16
|
-
end
|
17
|
-
|
18
|
-
test "block style" do
|
19
|
-
assert_dom_equal(%(<turbo-frame id="tray"><p>tray!</p></turbo-frame>), turbo_frame_tag("tray") { tag.p("tray!") })
|
20
|
-
end
|
21
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "turbo_test"
|
2
|
-
|
3
|
-
class Turbo::Native::NavigationControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
test "recede, resume, or refresh when native or redirect when not" do
|
5
|
-
%w[ recede resume refresh ].each do |action|
|
6
|
-
post trays_path, params: { return_to: "#{action}_or_redirect" }
|
7
|
-
assert_redirected_to tray_path(id: 1)
|
8
|
-
|
9
|
-
post trays_path, params: { return_to: "#{action}_or_redirect" }, headers: header_for_turbo_native_app
|
10
|
-
assert_redirected_to send("turbo_#{action}_historical_location_url")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
test "recede, resume, or refresh when native or redirect back when not" do
|
15
|
-
%w[ recede resume refresh ].each do |action|
|
16
|
-
post trays_path, params: { return_to: "#{action}_or_redirect_back" }
|
17
|
-
assert_redirected_to tray_path(id: 5)
|
18
|
-
|
19
|
-
post trays_path, params: { return_to: "#{action}_or_redirect_back" }, headers: header_for_referer
|
20
|
-
assert_redirected_to "/past_place"
|
21
|
-
|
22
|
-
post trays_path, params: { return_to: "#{action}_or_redirect_back" }, headers: header_for_turbo_native_app.merge(header_for_referer)
|
23
|
-
assert_redirected_to send("turbo_#{action}_historical_location_url")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
test "historical location url sends text/html" do
|
28
|
-
get turbo_refresh_historical_location_url
|
29
|
-
|
30
|
-
assert_response :ok
|
31
|
-
assert_equal "text/html; charset=utf-8", response.content_type
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def header_for_turbo_native_app
|
36
|
-
{ "HTTP_USER_AGENT" => "MyApp iOS/3.0 Turbo Native (build 13; iPad Air 2); iOS 9.3" }
|
37
|
-
end
|
38
|
-
|
39
|
-
def header_for_referer
|
40
|
-
{ "HTTP_REFERER" => "/past_place" }
|
41
|
-
end
|
42
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require "turbo_test"
|
2
|
-
require "action_cable"
|
3
|
-
|
4
|
-
class Turbo::BroadcastableTest < ActionCable::Channel::TestCase
|
5
|
-
include ActiveJob::TestHelper, Turbo::Streams::ActionHelper
|
6
|
-
|
7
|
-
setup { @message = Message.new(record_id: 1, content: "Hello!") }
|
8
|
-
|
9
|
-
test "broadcasting remove to stream now" do
|
10
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("remove", target: "message_1") do
|
11
|
-
@message.broadcast_remove_to "stream"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
test "broadcasting remove now" do
|
16
|
-
assert_broadcast_on @message.to_param, turbo_stream_action_tag("remove", target: "message_1") do
|
17
|
-
@message.broadcast_remove
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
test "broadcasting replace to stream now" do
|
22
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("replace", target: "message_1", template: "<p>Hello!</p>") do
|
23
|
-
@message.broadcast_replace_to "stream"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
test "broadcasting replace now" do
|
28
|
-
assert_broadcast_on @message.to_param, turbo_stream_action_tag("replace", target: "message_1", template: "<p>Hello!</p>") do
|
29
|
-
@message.broadcast_replace
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
test "broadcasting append to stream now" do
|
34
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("append", target: "messages", template: "<p>Hello!</p>") do
|
35
|
-
@message.broadcast_append_to "stream"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
test "broadcasting append to stream with custom target now" do
|
40
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("append", target: "board_messages", template: "<p>Hello!</p>") do
|
41
|
-
@message.broadcast_append_to "stream", target: "board_messages"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
test "broadcasting append now" do
|
46
|
-
assert_broadcast_on @message.to_param, turbo_stream_action_tag("append", target: "messages", template: "<p>Hello!</p>") do
|
47
|
-
@message.broadcast_append
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
test "broadcasting prepend to stream now" do
|
52
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("prepend", target: "messages", template: "<p>Hello!</p>") do
|
53
|
-
@message.broadcast_prepend_to "stream"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
test "broadcasting prepend to stream with custom target now" do
|
58
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("prepend", target: "board_messages", template: "<p>Hello!</p>") do
|
59
|
-
@message.broadcast_prepend_to "stream", target: "board_messages"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
test "broadcasting prepend now" do
|
64
|
-
assert_broadcast_on @message.to_param, turbo_stream_action_tag("prepend", target: "messages", template: "<p>Hello!</p>") do
|
65
|
-
@message.broadcast_prepend
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
test "broadcasting action to stream now" do
|
70
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("prepend", target: "messages", template: "<p>Hello!</p>") do
|
71
|
-
@message.broadcast_action_to "stream", action: "prepend"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
test "broadcasting action now" do
|
76
|
-
assert_broadcast_on @message.to_param, turbo_stream_action_tag("prepend", target: "messages", template: "<p>Hello!</p>") do
|
77
|
-
@message.broadcast_action "prepend"
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
require "turbo_test"
|
2
|
-
require "action_cable"
|
3
|
-
|
4
|
-
class Turbo::StreamsChannelTest < ActionCable::Channel::TestCase
|
5
|
-
include ActiveJob::TestHelper, Turbo::Streams::ActionHelper
|
6
|
-
|
7
|
-
test "verified stream name" do
|
8
|
-
assert_equal "stream", Turbo::StreamsChannel.verified_stream_name(Turbo::StreamsChannel.signed_stream_name("stream"))
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
test "broadcasting remove now" do
|
13
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("remove", target: "message_1") do
|
14
|
-
Turbo::StreamsChannel.broadcast_remove_to "stream", target: "message_1"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
test "broadcasting remove now with record" do
|
19
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("remove", target: "message_1") do
|
20
|
-
Turbo::StreamsChannel.broadcast_remove_to "stream", target: Message.new(record_id: 1, content: "hello!")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
test "broadcasting replace now" do
|
25
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("replace", target: "message_1", template: "<p>hello!</p>") do
|
26
|
-
Turbo::StreamsChannel.broadcast_replace_to "stream", target: "message_1", partial: "messages/message", locals: { message: "hello!" }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
test "broadcasting append now" do
|
31
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("append", target: "messages", template: "<p>hello!</p>") do
|
32
|
-
Turbo::StreamsChannel.broadcast_append_to "stream", target: "messages", partial: "messages/message", locals: { message: "hello!" }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
test "broadcasting prepend now" do
|
37
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("prepend", target: "messages", template: "<p>hello!</p>") do
|
38
|
-
Turbo::StreamsChannel.broadcast_prepend_to "stream", target: "messages", partial: "messages/message", locals: { message: "hello!" }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
test "broadcasting action now" do
|
43
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("prepend", target: "messages", template: "<p>hello!</p>") do
|
44
|
-
Turbo::StreamsChannel.broadcast_action_to "stream", action: "prepend", target: "messages", partial: "messages/message", locals: { message: "hello!" }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
test "broadcasting replace later" do
|
50
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("replace", target: "message_1", template: "<p>hello!</p>") do
|
51
|
-
perform_enqueued_jobs do
|
52
|
-
Turbo::StreamsChannel.broadcast_replace_later_to \
|
53
|
-
"stream", target: "message_1", partial: "messages/message", locals: { message: "hello!" }
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
test "broadcasting append later" do
|
59
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("append", target: "messages", template: "<p>hello!</p>") do
|
60
|
-
perform_enqueued_jobs do
|
61
|
-
Turbo::StreamsChannel.broadcast_append_later_to \
|
62
|
-
"stream", target: "messages", partial: "messages/message", locals: { message: "hello!" }
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
test "broadcasting prepend later" do
|
68
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("prepend", target: "messages", template: "<p>hello!</p>") do
|
69
|
-
perform_enqueued_jobs do
|
70
|
-
Turbo::StreamsChannel.broadcast_prepend_later_to \
|
71
|
-
"stream", target: "messages", partial: "messages/message", locals: { message: "hello!" }
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
test "broadcasting action later" do
|
77
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("prepend", target: "messages", template: "<p>hello!</p>") do
|
78
|
-
perform_enqueued_jobs do
|
79
|
-
Turbo::StreamsChannel.broadcast_action_later_to \
|
80
|
-
"stream", action: "prepend", target: "messages", partial: "messages/message", locals: { message: "hello!" }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
test "broadcasting render now" do
|
87
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("replace", target: "message_1", template: "Goodbye!") do
|
88
|
-
Turbo::StreamsChannel.broadcast_render_to "stream", partial: "messages/message"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
test "broadcasting render later" do
|
93
|
-
assert_broadcast_on "stream", turbo_stream_action_tag("replace", target: "message_1", template: "Goodbye!") do
|
94
|
-
perform_enqueued_jobs do
|
95
|
-
Turbo::StreamsChannel.broadcast_render_later_to "stream", partial: "messages/message"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
test "broadcasting update now" do
|
101
|
-
assert_broadcast_on "stream", %(direct) do
|
102
|
-
Turbo::StreamsChannel.broadcast_stream_to "stream", content: "direct"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require "turbo_test"
|
2
|
-
|
3
|
-
class Turbo::StreamsControllerTest < ActionDispatch::IntegrationTest
|
4
|
-
test "create with respond to" do
|
5
|
-
post messages_path
|
6
|
-
assert_redirected_to message_path(id: 1)
|
7
|
-
|
8
|
-
post messages_path, as: :turbo_stream
|
9
|
-
assert_response :ok
|
10
|
-
assert_turbo_stream action: :append, target: "messages" do |selected|
|
11
|
-
assert_equal "<template>message_1</template>", selected.children.to_html
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
test "show all turbo actions" do
|
16
|
-
get message_path(id: 1), as: :turbo_stream
|
17
|
-
assert_equal <<-STREAM, @response.body
|
18
|
-
<turbo-stream action="remove" target="message_1"></turbo-stream>
|
19
|
-
<turbo-stream action="replace" target="message_1"><template><p>My message</p></template></turbo-stream>
|
20
|
-
<turbo-stream action="replace" target="message_1"><template>Something else</template></turbo-stream>
|
21
|
-
<turbo-stream action="replace" target="message_5"><template>Something fifth</template></turbo-stream>
|
22
|
-
<turbo-stream action="replace" target="message_5"><template><p>OLLA!</p></template></turbo-stream>
|
23
|
-
<turbo-stream action="append" target="messages"><template><p>My message</p></template></turbo-stream>
|
24
|
-
<turbo-stream action="append" target="messages"><template><p>OLLA!</p></template></turbo-stream>
|
25
|
-
<turbo-stream action="prepend" target="messages"><template><p>My message</p></template></turbo-stream>
|
26
|
-
<turbo-stream action="prepend" target="messages"><template><p>OLLA!</p></template></turbo-stream>
|
27
|
-
STREAM
|
28
|
-
end
|
29
|
-
end
|
data/test/turbo_test.rb
DELETED
data/turbo-rails.gemspec
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require_relative "lib/turbo/version"
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = "turbo-rails"
|
5
|
-
s.version = Turbo::VERSION
|
6
|
-
s.authors = [ "Sam Stephenson", "Javan Mahkmali", "David Heinemeier Hansson" ]
|
7
|
-
s.email = "david@loudthinking.com"
|
8
|
-
s.summary = "The speed of a single-page web application without having to write any JavaScript."
|
9
|
-
s.homepage = "https://github.com/hotwired/turbo-rails"
|
10
|
-
s.license = "MIT"
|
11
|
-
|
12
|
-
s.required_ruby_version = ">= 2.6.0"
|
13
|
-
s.add_dependency "rails", ">= 6.0.0"
|
14
|
-
|
15
|
-
s.files = `git ls-files`.split("\n")
|
16
|
-
s.test_files = `git ls-files -- test/*`.split("\n")
|
17
|
-
end
|