render_turbo_stream 0.1.11 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- 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: 9de1041648648938b0c80d1c55e0e4b891528efbe92d1a80e063db1408d33934
|
4
|
+
data.tar.gz: 11078d44a6e593b4409a4110e2bb99574f1b09bf487c890a929902d5a43550fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 801afcaa11485be7be69514166552910ede01a3a00d26899780935e29d53c9201f4d502ad214065935fd2b0f0699b9f5ccb71e6d78baf03495f8dd80c2e154a9
|
7
|
+
data.tar.gz: d3aee9bd2741bf7c6596fa5e8156aed73260ed47a9487b5a26e75b798f5eeb0108be1dac23a683e0055ae3edb28d47a3054531c41836a4008f9eb9cf351cca54
|
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.13
|
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, sets status, and renders turbo-stream partials.
|
29
|
+
You can control your turbo-stream partials directly from the controller. It also
|
30
|
+
handles 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: []
|