render_turbo_stream 1.4.1 → 1.4.2

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: 395968d08aa5420fbd50bb63bccb641098503d33002a36a1a9f753b52caaae2b
4
- data.tar.gz: 537a3ed1c128c26df63083c545c7ba53c02167c30a38a69adf08261bbb27e069
3
+ metadata.gz: cf65f7ac19c9387a4ee6a42f9e2227082ec7996aef74e672cc45aa04f75becf7
4
+ data.tar.gz: 558ecbee422b8eab39c292f82ae0df3df54cc5b439b0e8a7b83008dc863e00ec
5
5
  SHA512:
6
- metadata.gz: a793feeaa175a29b27bd2811f6248de5e5e913224f455547b6fdb5cd1707e36f76d3e2b23824cd3c4a2c7197a5c25e50f99800c355ed0b55c76bae78f127586a
7
- data.tar.gz: 0d0294aed7dc3c57e580d34a939145c3ccd423a434da2bfad40d8daf7a769b3e4efece554d814a4f533f0eb21fb1efcdba4d223a6fc701106434635bd2e58a32
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
- # Check the content inside at least one in any of the elements that match the given css and check the id that turbo has pointed to..
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` always returns the number of matched responses.
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). That should be enough for this level. For more detailed testing of partials, there are view tests. And many of the partials are regularly accessed in two ways, for example a `form': it is pushed by turbo_stream as well as by calling edit_customer_path.
245
+ Possible matchers can be found at [Nokogiri](https://nokogiri.org/tutorials/searching_a_xml_html_document.html).
246
246
 
247
- P.S.:
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.
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.2"
3
3
  end
@@ -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 && redirect_on_success_to.present?
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
- redirect_on_success_to
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
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: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian