render_turbo_stream 1.4.1 → 1.4.2
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 +7 -5
- data/lib/render_turbo_stream/version.rb +1 -1
- data/lib/render_turbo_stream.rb +15 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf65f7ac19c9387a4ee6a42f9e2227082ec7996aef74e672cc45aa04f75becf7
|
4
|
+
data.tar.gz: 558ecbee422b8eab39c292f82ae0df3df54cc5b439b0e8a7b83008dc863e00ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11549d8a9b8145ca04e7e025516a74edbeeb726bfa9d3bfca0fa819c2d8bf76da7d354c860ec01ec461b4d50b80e0fb197aaf34b30502b1d29d72718982cf149
|
7
|
+
data.tar.gz: 8405143aeae7793da5011b56e5993843dac2f0f97c5d0cce712d5fac0eca5a1e4045dd7680b72db76f6c5c761dd35f7f3fa24fb71e029dbde6bda8b49b140281
|
data/README.md
CHANGED
@@ -195,7 +195,7 @@ it 'update failed' do
|
|
195
195
|
expect_successful_saved('customer-form', 'flash-box')
|
196
196
|
# expects response.status 200
|
197
197
|
# Make sure that the responses point to exactly these 2 IDs ('form' and 'flash-box').
|
198
|
-
# Make sure that each ID is responded to exactly once.
|
198
|
+
# Make sure that to each ID is responded to exactly once.
|
199
199
|
end
|
200
200
|
```
|
201
201
|
|
@@ -218,7 +218,7 @@ expect(stream_response('customer-form')).to eq(true)
|
|
218
218
|
# Make sure that the id «customer-form» is targeted exactly once.
|
219
219
|
|
220
220
|
expect(stream_response('customer-form', css: '.field_with_errors', include_string: 'Title')).to eq(true)
|
221
|
-
#
|
221
|
+
# Verify that the response targeted to "customer-form" contains the specified html.
|
222
222
|
```
|
223
223
|
|
224
224
|
**More detailed**
|
@@ -240,11 +240,13 @@ expect(
|
|
240
240
|
end
|
241
241
|
).to eq(1)
|
242
242
|
```
|
243
|
-
`stream_target_response_count`
|
243
|
+
`stream_target_response_count` returns the number of matched responses.
|
244
244
|
|
245
|
-
Possible matchers can be found at [Nokogiri](https://nokogiri.org/tutorials/searching_a_xml_html_document.html).
|
245
|
+
Possible matchers can be found at [Nokogiri](https://nokogiri.org/tutorials/searching_a_xml_html_document.html).
|
246
246
|
|
247
|
-
|
247
|
+
For more detailed testing of partials, there are view tests.
|
248
|
+
|
249
|
+
**P.S.:**
|
248
250
|
|
249
251
|
Testing the plugin itself: There is a [quick-and-dirty app](https://gitlab.com/sedl/renderturbostream_railsapp) which
|
250
252
|
includes the plugin and has tests done by rspec/request and capybara.
|
data/lib/render_turbo_stream.rb
CHANGED
@@ -8,7 +8,8 @@ module RenderTurboStream
|
|
8
8
|
|
9
9
|
def turbo_stream_save(
|
10
10
|
save_action,
|
11
|
-
redirect_on_success_to: nil,
|
11
|
+
redirect_on_success_to: nil, # does a regular redirect. Works if you are inside a turbo_frame and just want to redirect inside that frame
|
12
|
+
turbo_redirect_on_success_to: nil, # does a full page redirect (break out of all frames by turbo_power redirect)
|
12
13
|
object: nil, # object used in save_action, example: @customer
|
13
14
|
id: 'form', # if nil: no partial is rendered
|
14
15
|
partial: nil, # example: 'customers/form' default: "#{controller_path}/#{id}"
|
@@ -122,16 +123,27 @@ module RenderTurboStream
|
|
122
123
|
|
123
124
|
#== render
|
124
125
|
|
125
|
-
if save_action &&
|
126
|
+
if save_action && turbo_redirect_on_success_to.present?
|
126
127
|
response.status = 302
|
127
128
|
flash[:alert] = flash_alerts
|
128
129
|
flash[:notice] = flash_notices
|
129
130
|
render_turbo_stream([
|
130
131
|
[
|
131
132
|
:redirect_to,
|
132
|
-
|
133
|
+
turbo_redirect_on_success_to
|
133
134
|
]
|
134
135
|
])
|
136
|
+
elsif save_action && redirect_on_success_to.present?
|
137
|
+
response.status = 302
|
138
|
+
flash.now[:alert] = flash_alerts
|
139
|
+
flash.now[:notice] = flash_notices
|
140
|
+
render_turbo_stream([
|
141
|
+
[
|
142
|
+
:redirect_to,
|
143
|
+
turbo_redirect_on_success_to
|
144
|
+
]
|
145
|
+
])
|
146
|
+
|
135
147
|
else
|
136
148
|
flash.now[:alert] = flash_alerts
|
137
149
|
flash.now[:notice] = flash_notices
|