turbo-rails 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -1
  3. data/app/assets/javascripts/turbo.js +243 -129
  4. data/app/helpers/turbo/streams_helper.rb +2 -2
  5. data/lib/install/turbo_with_webpacker.rb +1 -2
  6. data/lib/turbo/engine.rb +1 -1
  7. data/lib/turbo/version.rb +1 -1
  8. metadata +7 -173
  9. data/.github/workflows/ci.yml +0 -30
  10. data/.gitignore +0 -2
  11. data/Gemfile +0 -6
  12. data/Gemfile.lock +0 -147
  13. data/package.json +0 -47
  14. data/rollup.config.js +0 -23
  15. data/test/drive/drive_helper_test.rb +0 -8
  16. data/test/dummy/.babelrc +0 -18
  17. data/test/dummy/.gitignore +0 -3
  18. data/test/dummy/.postcssrc.yml +0 -3
  19. data/test/dummy/Rakefile +0 -6
  20. data/test/dummy/app/assets/config/manifest.js +0 -2
  21. data/test/dummy/app/assets/images/.keep +0 -0
  22. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  23. data/test/dummy/app/assets/stylesheets/scaffold.css +0 -80
  24. data/test/dummy/app/channels/application_cable/channel.rb +0 -4
  25. data/test/dummy/app/channels/application_cable/connection.rb +0 -4
  26. data/test/dummy/app/controllers/application_controller.rb +0 -2
  27. data/test/dummy/app/controllers/concerns/.keep +0 -0
  28. data/test/dummy/app/controllers/messages_controller.rb +0 -12
  29. data/test/dummy/app/controllers/trays_controller.rb +0 -17
  30. data/test/dummy/app/helpers/application_helper.rb +0 -2
  31. data/test/dummy/app/javascript/packs/application.js +0 -0
  32. data/test/dummy/app/jobs/application_job.rb +0 -2
  33. data/test/dummy/app/mailboxes/application_mailbox.rb +0 -2
  34. data/test/dummy/app/mailboxes/messages_mailbox.rb +0 -4
  35. data/test/dummy/app/mailers/application_mailer.rb +0 -4
  36. data/test/dummy/app/models/application_record.rb +0 -3
  37. data/test/dummy/app/models/concerns/.keep +0 -0
  38. data/test/dummy/app/models/message.rb +0 -29
  39. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  40. data/test/dummy/app/views/layouts/mailer.html.erb +0 -13
  41. data/test/dummy/app/views/layouts/mailer.text.erb +0 -1
  42. data/test/dummy/app/views/messages/_message.html.erb +0 -1
  43. data/test/dummy/app/views/messages/_message.turbo_stream.erb +0 -1
  44. data/test/dummy/app/views/messages/show.turbo_stream.erb +0 -9
  45. data/test/dummy/app/views/trays/index.html.erb +0 -3
  46. data/test/dummy/app/views/trays/show.html.erb +0 -3
  47. data/test/dummy/bin/bundle +0 -3
  48. data/test/dummy/bin/rails +0 -4
  49. data/test/dummy/bin/rake +0 -4
  50. data/test/dummy/bin/setup +0 -36
  51. data/test/dummy/bin/update +0 -31
  52. data/test/dummy/bin/yarn +0 -11
  53. data/test/dummy/config.ru +0 -5
  54. data/test/dummy/config/application.rb +0 -22
  55. data/test/dummy/config/boot.rb +0 -5
  56. data/test/dummy/config/cable.yml +0 -10
  57. data/test/dummy/config/environment.rb +0 -5
  58. data/test/dummy/config/environments/development.rb +0 -34
  59. data/test/dummy/config/environments/production.rb +0 -96
  60. data/test/dummy/config/environments/test.rb +0 -38
  61. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
  62. data/test/dummy/config/initializers/assets.rb +0 -14
  63. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  64. data/test/dummy/config/initializers/content_security_policy.rb +0 -22
  65. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  66. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  67. data/test/dummy/config/initializers/inflections.rb +0 -16
  68. data/test/dummy/config/initializers/mime_types.rb +0 -4
  69. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  70. data/test/dummy/config/locales/en.yml +0 -33
  71. data/test/dummy/config/puma.rb +0 -34
  72. data/test/dummy/config/routes.rb +0 -4
  73. data/test/dummy/config/spring.rb +0 -6
  74. data/test/dummy/config/webpack/development.js +0 -3
  75. data/test/dummy/config/webpack/environment.js +0 -3
  76. data/test/dummy/config/webpack/production.js +0 -3
  77. data/test/dummy/config/webpack/test.js +0 -3
  78. data/test/dummy/config/webpacker.yml +0 -65
  79. data/test/dummy/lib/assets/.keep +0 -0
  80. data/test/dummy/log/.keep +0 -0
  81. data/test/dummy/public/404.html +0 -67
  82. data/test/dummy/public/422.html +0 -67
  83. data/test/dummy/public/500.html +0 -66
  84. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  85. data/test/dummy/public/apple-touch-icon.png +0 -0
  86. data/test/dummy/public/favicon.ico +0 -0
  87. data/test/frames/frame_request_controller_test.rb +0 -21
  88. data/test/frames/frames_helper_test.rb +0 -21
  89. data/test/native/navigation_controller_test.rb +0 -42
  90. data/test/streams/broadcastable_test.rb +0 -80
  91. data/test/streams/streams_channel_test.rb +0 -111
  92. data/test/streams/streams_controller_test.rb +0 -29
  93. data/test/turbo_test.rb +0 -10
  94. data/turbo-rails.gemspec +0 -17
  95. data/yarn.lock +0 -283
@@ -1,4 +0,0 @@
1
- Rails.application.routes.draw do
2
- resources :messages
3
- resources :trays
4
- end
@@ -1,6 +0,0 @@
1
- %w[
2
- .ruby-version
3
- .rbenv-vars
4
- tmp/restart.txt
5
- tmp/caching-dev.txt
6
- ].each { |path| Spring.watch(path) }
@@ -1,3 +0,0 @@
1
- const environment = require('./environment')
2
-
3
- module.exports = environment.toWebpackConfig()
@@ -1,3 +0,0 @@
1
- const { environment } = require('@rails/webpacker')
2
-
3
- module.exports = environment
@@ -1,3 +0,0 @@
1
- const environment = require('./environment')
2
-
3
- module.exports = environment.toWebpackConfig()
@@ -1,3 +0,0 @@
1
- const environment = require('./environment')
2
-
3
- module.exports = environment.toWebpackConfig()
@@ -1,65 +0,0 @@
1
- # Note: You must restart bin/webpack-dev-server for changes to take effect
2
-
3
- default: &default
4
- source_path: app/javascript
5
- source_entry_path: packs
6
- public_output_path: packs
7
- cache_path: tmp/cache/webpacker
8
-
9
- # Additional paths webpack should lookup modules
10
- # ['app/assets', 'engine/foo/app/assets']
11
- resolved_paths: []
12
-
13
- # Reload manifest.json on all requests so we reload latest compiled packs
14
- cache_manifest: false
15
-
16
- extensions:
17
- - .js
18
- - .sass
19
- - .scss
20
- - .css
21
- - .png
22
- - .svg
23
- - .gif
24
- - .jpeg
25
- - .jpg
26
-
27
- development:
28
- <<: *default
29
- compile: true
30
-
31
- # Reference: https://webpack.js.org/configuration/dev-server/
32
- dev_server:
33
- https: false
34
- host: localhost
35
- port: 3035
36
- public: localhost:3035
37
- hmr: false
38
- # Inline should be set to true if using HMR
39
- inline: true
40
- overlay: true
41
- compress: true
42
- disable_host_check: true
43
- use_local_ip: false
44
- quiet: false
45
- headers:
46
- 'Access-Control-Allow-Origin': '*'
47
- watch_options:
48
- ignored: /node_modules/
49
-
50
-
51
- test:
52
- <<: *default
53
- compile: true
54
-
55
- # Compile test packs to a separate directory
56
- public_output_path: packs-test
57
-
58
- production:
59
- <<: *default
60
-
61
- # Production depends on precompilation of packs prior to booting for performance.
62
- compile: false
63
-
64
- # Cache manifest.json for performance
65
- cache_manifest: true
File without changes
File without changes
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</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/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -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>
@@ -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
@@ -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