render_turbo_stream 1.4.1 → 1.4.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: 395968d08aa5420fbd50bb63bccb641098503d33002a36a1a9f753b52caaae2b
4
- data.tar.gz: 537a3ed1c128c26df63083c545c7ba53c02167c30a38a69adf08261bbb27e069
3
+ metadata.gz: 740e9df76f8c575bc3a993c3bc3ad524d70e1a4593c21906ca41d16dc426399b
4
+ data.tar.gz: 6ea17ebf4b85712130b3b5289cecffcf76d043cb6d1638bfa68f27c7d1aa7494
5
5
  SHA512:
6
- metadata.gz: a793feeaa175a29b27bd2811f6248de5e5e913224f455547b6fdb5cd1707e36f76d3e2b23824cd3c4a2c7197a5c25e50f99800c355ed0b55c76bae78f127586a
7
- data.tar.gz: 0d0294aed7dc3c57e580d34a939145c3ccd423a434da2bfad40d8daf7a769b3e4efece554d814a4f533f0eb21fb1efcdba4d223a6fc701106434635bd2e58a32
6
+ metadata.gz: 4dd54e9153f44bc4e6104132d75f1b7ad9613569f8f2c49c5b0a44711aacb6eac92c0c77a82bec52b82491b3450010fcffc581221340d5510c0f87bcf2650b74
7
+ data.tar.gz: e337836ec7353f535236f6e9aac1b7aa4c514d3eb370464bfb6cc7499f32b41c3501c89146a864781b15ba6145d2849439fb91564676f9a0b3a2b197ea686455
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.3"
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,23 @@ 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(streams)
141
+ redirect_to redirect_on_success_to
142
+
135
143
  else
136
144
  flash.now[:alert] = flash_alerts
137
145
  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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian