render_turbo_stream 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +24 -10
- data/lib/render_turbo_stream/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa9b9cefa95d380af39fd2f096f569cb4eabe94fe024164722cae8497b7d076f
|
4
|
+
data.tar.gz: 9973fe128954730c6b1dc9f52ecc63a6b633951d118f06eae0e2672c54a519d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1738911b840851ed5d3974702bea36029f8bcb453786b5524bef7c1f2fee0ee78dccfc0f275e8e5f72b724f787425aa13f821c7c251c5ad92876c5c728b2bad5
|
7
|
+
data.tar.gz: 6be68eb76a040ab06fb97380d80d03ce16e55096819062a5c8760604a5d9df5808ba1c72229afe7a9807e9ec6c6e69a305b17be2a94ed110eae4ec8461c148cd
|
data/README.md
CHANGED
@@ -12,13 +12,19 @@ Currently it is only possible by copy and paste the code, see below.
|
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
15
|
-
|
15
|
+
```ruby
|
16
|
+
gem 'render_turbo_stream'
|
17
|
+
```
|
16
18
|
|
17
|
-
|
19
|
+
```shell
|
20
|
+
bundle install
|
21
|
+
```
|
18
22
|
|
19
|
-
|
23
|
+
**ApplicationController**
|
20
24
|
|
21
|
-
|
25
|
+
```ruby
|
26
|
+
include RenderTurboStream
|
27
|
+
```
|
22
28
|
|
23
29
|
The corresponding partials for flashes could look [like this](https://gitlab.com/sedl/renderturbostream/-/wikis/flashes)
|
24
30
|
|
@@ -72,13 +78,9 @@ stream_partial(
|
|
72
78
|
For system testing you need capybara.
|
73
79
|
|
74
80
|
For enabling request specs:
|
75
|
-
If `request.format` is not `turbo_stream` the method responds as `json` with status:
|
76
|
-
|
77
|
-
Success and redirection: `302`
|
78
|
-
Success without redirection: `200`
|
79
|
-
Save Action failed: `422` `:unprocessable_entity`
|
80
81
|
|
81
|
-
|
82
|
+
If `request.format` is not `turbo_stream` the method responds as `json` with status.
|
83
|
+
`response.body` returns a `json` where the key is the `html-ID` that is used by turbo-stream with the properties of the partials. Testing by rspec could look like this:
|
82
84
|
|
83
85
|
```ruby
|
84
86
|
it 'update failed' do
|
@@ -92,6 +94,18 @@ it 'update failed' do
|
|
92
94
|
end
|
93
95
|
```
|
94
96
|
|
97
|
+
Test for a redirection could look like this:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
it 'update success' do
|
101
|
+
a = FactoryBot.create(:article)
|
102
|
+
patch article_path(a, params: valid_params)
|
103
|
+
expect(response.status).to eq(302)
|
104
|
+
r = JSON.parse(response.body)
|
105
|
+
expect(r['redirected_to']).to eq(articles_path)
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
95
109
|
## Parameters
|
96
110
|
|
97
111
|
`save_action` (first parameter, boolean) true if successful
|
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: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- christian
|
@@ -24,7 +24,10 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 7.0.4.3
|
27
|
-
description:
|
27
|
+
description: 'Writing views like (create|update).turbo_stream.haml annoyed me. This
|
28
|
+
gem handles translated flash messages, set status and renders turbo-stream partials.
|
29
|
+
You can steer your turbo-stream partials directly from the contoller. It also handles
|
30
|
+
redirection: turbo_power is included.'
|
28
31
|
email:
|
29
32
|
- christian@sedlmair.ch
|
30
33
|
executables: []
|
@@ -66,5 +69,5 @@ requirements: []
|
|
66
69
|
rubygems_version: 3.4.12
|
67
70
|
signing_key:
|
68
71
|
specification_version: 4
|
69
|
-
summary:
|
72
|
+
summary: Rendering turbo-stream partials directly from controller
|
70
73
|
test_files: []
|