render_turbo_stream 0.1.11 → 0.1.12

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: fbc78913dcbad95c4f8de2b0188ab6eff2db1ac2390590a491427af071f2fa55
4
- data.tar.gz: c2d381f27a631862490811f5c140f91245370ad3b1b82e3ba41771707adae732
3
+ metadata.gz: aa9b9cefa95d380af39fd2f096f569cb4eabe94fe024164722cae8497b7d076f
4
+ data.tar.gz: 9973fe128954730c6b1dc9f52ecc63a6b633951d118f06eae0e2672c54a519d2
5
5
  SHA512:
6
- metadata.gz: 5873014fd22b2b1d4d2ded650f37bdc5f6e865ada01608c82ad2c891199c1e342bb6e7a4d94319c6e92c0cfea196fb19230cdebc931915fb2b2e420cc3ab1653
7
- data.tar.gz: 854105573f8b7a5b8f34ac031d93c4e0a01eb2f5b4263a1495cfac17d53a391431c0ec5a339a5666e4ec8340d029218c2914501fba1a65869508185661d0eab9
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
- Because of [that issue](https://github.com/rails/rails/issues/47954) appying this feature is currently only possible by copy and paste following files to your app
15
+ ```ruby
16
+ gem 'render_turbo_stream'
17
+ ```
16
18
 
17
- [application_controller](https://gitlab.com/sedl/renderturbostream/-/wikis/application_controller)
19
+ ```shell
20
+ bundle install
21
+ ```
18
22
 
19
- [layout/render_partials.turbo_stream.erb](https://gitlab.com/sedl/renderturbostream/-/wikis/layout/render.turbo_stream.erb)
23
+ **ApplicationController**
20
24
 
21
- [layouts/render_redirect.turbo_stream.erb](https://gitlab.com/sedl/renderturbostream/-/wikis/layouts/render_redirect.turbo_stream.erb)
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
- Testing the `response.body` by rspec could look like this:
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
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
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.11
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: Coming soon
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: Coming soon
72
+ summary: Rendering turbo-stream partials directly from controller
70
73
  test_files: []