render_turbo_stream 2.0.1 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a57490a46044d10e1ee83f31c08f76a5b276b0687131462fe166d89405f3064
|
4
|
+
data.tar.gz: ae6fbdc64456d787eae9e3453ce1d08d943239f390f234091e71a0d20ef88ff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3facc3277258f03cae9e2185709f8594aa7c2b81b2b30735ba645a634ca89f16c7895cfda88a1d21252f0121ac2413bfeac03a1dcdb9f73d698f7c491a6b58a
|
7
|
+
data.tar.gz: 4cb888a09b19291463fdf612b6f33e55f83dfc5e01e0afca2dd477ff512321e528b07f7677c0e78b3458237db594083b0a0540636471deacdb49e153e73e7fae
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# RenderTurboStream
|
2
2
|
|
3
|
-
Defining templates like `(create|update).turbo_stream.haml` annoyed me.
|
4
|
-
|
5
|
-
The biggest advantage of this gem is the testing strategy.
|
3
|
+
Defining templates like `(create|update).turbo_stream.haml` annoyed me and I was looking for a testing strategy.
|
6
4
|
|
7
5
|
Working consistently with turbo_stream means shooting lots of partials from the backend to the frontend. This always requires the same attributes: the path to the partial, the html-id that turbo_stream points to, and maybe some locals. This gem serialises that: Partials can be controlled directly from the controller. It sets the status, generates a flash message, handles redirection, pushes it all to the front. Includes helpers for enabling request tests.
|
8
6
|
|
@@ -11,7 +11,6 @@ module RenderTurboStream
|
|
11
11
|
def cable_partial_to_channel(action, channel, partial, id, locals: nil)
|
12
12
|
|
13
13
|
# add headers for test
|
14
|
-
|
15
14
|
if Rails.env.test?
|
16
15
|
args = {
|
17
16
|
target: "##{id}",
|
@@ -20,12 +19,14 @@ module RenderTurboStream
|
|
20
19
|
partial: partial,
|
21
20
|
locals: locals
|
22
21
|
}
|
22
|
+
html = RenderTurboStreamRenderController.render(partial: partial, locals: locals)
|
23
23
|
h = response.headers.to_h
|
24
24
|
i = 1
|
25
25
|
loop do
|
26
26
|
k = "test-turbo-cable-#{i}"
|
27
27
|
unless h.keys.include?(k)
|
28
28
|
response.headers[k] = args.to_json
|
29
|
+
response.headers["#{k}-html"] = html.to_s
|
29
30
|
break
|
30
31
|
end
|
31
32
|
i += 1
|
data/lib/render_turbo_stream.rb
CHANGED
@@ -245,7 +245,8 @@ module RenderTurboStream
|
|
245
245
|
cables = response.headers.to_h.select { |k| k.match(/^test-turbo-cable-[\d]+$/) }
|
246
246
|
cables.each do |k, v|
|
247
247
|
args = JSON.parse(v)
|
248
|
-
html = ApplicationController.render(partial: args['partial'], locals: args['locals'].symbolize_keys)
|
248
|
+
#html = ApplicationController.render(partial: args['partial'], locals: args['locals'].symbolize_keys)
|
249
|
+
html = response.headers["#{k}-html"]
|
249
250
|
res.push(
|
250
251
|
args.merge(
|
251
252
|
{
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_turbo_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- christian
|
@@ -24,11 +24,11 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 7.0.4.3
|
27
|
-
description:
|
28
|
-
|
29
|
-
templates. Together with the turbo_power gem or custom
|
30
|
-
can run javascript. Redirects can now be handled easily and in multiple
|
31
|
-
|
27
|
+
description: Handles translated flash messages, sets status and renders partials via
|
28
|
+
Turbo Stream or Turbo::StreamsChannel directly from the controller. No need to write
|
29
|
+
*.turbo_stream.* templates. Together with the turbo_power gem or custom turbo_stream
|
30
|
+
actions, you can run javascript. Redirects can now be handled easily and in multiple
|
31
|
+
ways. Enables a consistent testing strategy through request testing helpers.
|
32
32
|
email:
|
33
33
|
- christian@sedlmair.ch
|
34
34
|
executables: []
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- README.md
|
39
39
|
- Rakefile
|
40
40
|
- app/controllers/render_turbo_stream/application_controller.rb
|
41
|
+
- app/controllers/render_turbo_stream/render_turbo_stream_render_controller.rb
|
41
42
|
- app/models/render_turbo_stream/cable_stream.rb
|
42
43
|
- app/views/render_turbo_stream.html.erb
|
43
44
|
- app/views/render_turbo_stream.turbo_stream.erb
|