render_turbo_stream 0.1.33 → 0.1.34
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/render_turbo_stream/request_test_helpers.rb +31 -3
- data/lib/render_turbo_stream/version.rb +1 -1
- 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: 95e94563d2f1c54311f3755286e2ace6f4f258c63f443b305043cf2c7611cd4f
|
4
|
+
data.tar.gz: e7deed853515642b52503f1f870e436ad4870359320b7fc88d179e10b9d60943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a34007581d53530c7f96f1aff79af28594303c856dea1913708d913794a4020f8203c98ffd8a6538446e1a85295436a7d466ff1e09f3171615af7eac6afff781
|
7
|
+
data.tar.gz: f7fa39fbd0932a58112168abe638f323f1f3a3ae98d1ddd9fc700e504d741dfbc04dfb666ecd34cff42ff6b6ca0ab236ad94fbd05e48f55c8b75b5da19593c10
|
data/README.md
CHANGED
@@ -113,9 +113,10 @@ RSpec.describe "Articles", type: :request do
|
|
113
113
|
|
114
114
|
# --- BASIC TEST ---
|
115
115
|
|
116
|
-
#
|
116
|
+
# Count of rendered partials
|
117
117
|
expect(partials_count).to eq(2)
|
118
|
-
|
118
|
+
# Make sure that each of these partials is rendered exactly once.
|
119
|
+
expect(partials_once).to include('layouts/flash', 'articles/form')
|
119
120
|
|
120
121
|
|
121
122
|
|
@@ -53,8 +53,13 @@ module RenderTurboStream
|
|
53
53
|
paths
|
54
54
|
end
|
55
55
|
|
56
|
-
# array of strings of paths by which partials that are exactly one time rendered, for example: ['articles/form'].
|
57
|
-
|
56
|
+
# without arguments: returns array of strings of paths by which partials that are exactly one time rendered, for example: ['articles/form'].
|
57
|
+
# if arguments provided: compares with result and returns boolean
|
58
|
+
# examples:
|
59
|
+
# partials_once('articles/flash_box') => check flash-box is exactly one time rendered and no others
|
60
|
+
# partials_once({partial: 'articles/flash_box', id: 'flash-box'}) => check flash-box is exactly one time rendered
|
61
|
+
# partials_once({partial: 'articles/flash_box', id: 'flash-box'}) => check flash-box is exactly one time rendered to id 'flash-box'
|
62
|
+
def partials_once(*args)
|
58
63
|
ary = partials_attributes
|
59
64
|
paths = []
|
60
65
|
paths_once = []
|
@@ -66,7 +71,30 @@ module RenderTurboStream
|
|
66
71
|
paths_once.push(a['partial'])
|
67
72
|
end
|
68
73
|
end
|
69
|
-
|
74
|
+
if args.present?
|
75
|
+
paths_once
|
76
|
+
if args.length == paths_once.length
|
77
|
+
res = true
|
78
|
+
args.each do |a|
|
79
|
+
if a.is_a?(String) && !paths_once.include?(a)
|
80
|
+
res = false
|
81
|
+
elsif a.is_a?(Hash)
|
82
|
+
_a = a.symbolize_keys
|
83
|
+
if !paths_once.include?(_a[:partial])
|
84
|
+
res = false
|
85
|
+
elsif _a.key?(:id)
|
86
|
+
r = ary.select{|a|a['partial'] == _a[:partial]}.first
|
87
|
+
res = r['id'] == _a[:id]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
res
|
92
|
+
else
|
93
|
+
false
|
94
|
+
end
|
95
|
+
else
|
96
|
+
paths_once
|
97
|
+
end
|
70
98
|
end
|
71
99
|
|
72
100
|
# returns an array of hashes with the attributes used to call partials and the response (html as string) from the partial.
|