futurism 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +86 -84
- data/README.md +26 -0
- data/app/assets/javascripts/futurism.min.js.map +1 -1
- data/app/assets/javascripts/futurism.umd.min.js.map +1 -1
- data/futurism.gemspec +0 -3
- data/futurism.gemspec~ +1 -1
- data/lib/futurism/engine.rb +4 -0
- data/lib/futurism/helpers.rb +5 -5
- data/lib/futurism/options_transformer.rb +1 -1
- data/lib/futurism/resolver/controller/instrumentation.rb +33 -0
- data/lib/futurism/resolver/controller/renderer.rb +5 -1
- data/lib/futurism/resolver/resources.rb +3 -3
- data/lib/futurism/version.rb +1 -1
- data/lib/futurism.rb +11 -3
- data/package.json +1 -1
- data/package.json~ +2 -2
- data/yarn.lock +61 -21
- metadata +5 -94
- data/test/cable/channel_test.rb +0 -319
- data/test/dummy/app/channels/application_cable/channel.rb +0 -4
- data/test/dummy/app/channels/application_cable/connection.rb +0 -4
- data/test/dummy/app/controllers/application_controller.rb +0 -2
- data/test/dummy/app/controllers/home_controller.rb +0 -6
- data/test/dummy/app/controllers/posts_controller.rb +0 -59
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/posts_helper.rb +0 -2
- data/test/dummy/app/jobs/application_job.rb +0 -7
- data/test/dummy/app/models/action_item.rb +0 -2
- data/test/dummy/app/models/application_record.rb +0 -3
- data/test/dummy/app/models/post.rb +0 -2
- data/test/dummy/config/application.rb +0 -29
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -40
- data/test/dummy/config/environments/production.rb +0 -94
- data/test/dummy/config/environments/test.rb +0 -39
- data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/content_security_policy.rb +0 -28
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -9
- data/test/dummy/config/puma.rb +0 -38
- data/test/dummy/config/routes.rb +0 -12
- data/test/dummy/config/spring.rb +0 -6
- data/test/dummy/db/migrate/20200711122838_create_posts.rb +0 -9
- data/test/dummy/db/migrate/2021042923813_create_action_items.rb +0 -9
- data/test/dummy/db/schema.rb +0 -27
- data/test/futurism_test.rb +0 -28
- data/test/helper/helper_test.rb +0 -206
- data/test/integration/navigation_test.rb +0 -7
- data/test/resolver/controller/renderer_test.rb +0 -120
- data/test/resolver/controller_test.rb +0 -26
- data/test/test_helper.rb +0 -14
data/package.json
CHANGED
data/package.json~
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@stimulus_reflex/futurism",
|
3
|
-
"version": "1.2.0
|
3
|
+
"version": "1.2.0",
|
4
4
|
"description": "Lazy-load Rails partials via CableReady",
|
5
5
|
"main": "./dist/futurism.umd.min.js",
|
6
6
|
"module": "./dist/futurism.min.js",
|
@@ -33,7 +33,7 @@
|
|
33
33
|
},
|
34
34
|
"homepage": "https://github.com/stimulusreflex/futurism#readme",
|
35
35
|
"dependencies": {
|
36
|
-
"cable_ready": "^5.0.0
|
36
|
+
"cable_ready": "^5.0.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
39
|
"@rollup/plugin-commonjs": "^21.0.3",
|
data/yarn.lock
CHANGED
@@ -95,6 +95,46 @@
|
|
95
95
|
resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.3.tgz#f060bf6eaafae4d56a7dac618980838b0696e2ab"
|
96
96
|
integrity sha512-FmuxfCuolpLl0AnQ2NHSzoUKWEJDFl63qXjzdoWBVyFCXzMGm1spBzk7LeHNoVCiWCF7mRVms9e6jEV9+MoPbg==
|
97
97
|
|
98
|
+
"@jridgewell/gen-mapping@^0.3.0":
|
99
|
+
version "0.3.3"
|
100
|
+
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098"
|
101
|
+
integrity sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==
|
102
|
+
dependencies:
|
103
|
+
"@jridgewell/set-array" "^1.0.1"
|
104
|
+
"@jridgewell/sourcemap-codec" "^1.4.10"
|
105
|
+
"@jridgewell/trace-mapping" "^0.3.9"
|
106
|
+
|
107
|
+
"@jridgewell/resolve-uri@^3.1.0":
|
108
|
+
version "3.1.1"
|
109
|
+
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721"
|
110
|
+
integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==
|
111
|
+
|
112
|
+
"@jridgewell/set-array@^1.0.1":
|
113
|
+
version "1.1.2"
|
114
|
+
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
|
115
|
+
integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==
|
116
|
+
|
117
|
+
"@jridgewell/source-map@^0.3.3":
|
118
|
+
version "0.3.5"
|
119
|
+
resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.5.tgz#a3bb4d5c6825aab0d281268f47f6ad5853431e91"
|
120
|
+
integrity sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==
|
121
|
+
dependencies:
|
122
|
+
"@jridgewell/gen-mapping" "^0.3.0"
|
123
|
+
"@jridgewell/trace-mapping" "^0.3.9"
|
124
|
+
|
125
|
+
"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14":
|
126
|
+
version "1.4.15"
|
127
|
+
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
|
128
|
+
integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==
|
129
|
+
|
130
|
+
"@jridgewell/trace-mapping@^0.3.9":
|
131
|
+
version "0.3.19"
|
132
|
+
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz#f8a3249862f91be48d3127c3cfe992f79b4b8811"
|
133
|
+
integrity sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==
|
134
|
+
dependencies:
|
135
|
+
"@jridgewell/resolve-uri" "^3.1.0"
|
136
|
+
"@jridgewell/sourcemap-codec" "^1.4.14"
|
137
|
+
|
98
138
|
"@nodelib/fs.scandir@2.1.3":
|
99
139
|
version "2.1.3"
|
100
140
|
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b"
|
@@ -231,10 +271,10 @@ acorn@^7.1.1:
|
|
231
271
|
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.3.1.tgz#85010754db53c3fbaf3b9ea3e083aa5c5d147ffd"
|
232
272
|
integrity sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==
|
233
273
|
|
234
|
-
acorn@^8.
|
235
|
-
version "8.
|
236
|
-
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.
|
237
|
-
integrity sha512-
|
274
|
+
acorn@^8.8.2:
|
275
|
+
version "8.10.0"
|
276
|
+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5"
|
277
|
+
integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==
|
238
278
|
|
239
279
|
aggregate-error@^3.0.0:
|
240
280
|
version "3.0.1"
|
@@ -2633,15 +2673,20 @@ semver-compare@^1.0.0:
|
|
2633
2673
|
resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc"
|
2634
2674
|
integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w=
|
2635
2675
|
|
2636
|
-
semver@6.3.0
|
2676
|
+
semver@6.3.0:
|
2637
2677
|
version "6.3.0"
|
2638
2678
|
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
|
2639
2679
|
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
|
2640
2680
|
|
2641
2681
|
semver@^5.5.0, semver@^5.6.0:
|
2642
|
-
version "5.7.
|
2643
|
-
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.
|
2644
|
-
integrity sha512-
|
2682
|
+
version "5.7.2"
|
2683
|
+
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"
|
2684
|
+
integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==
|
2685
|
+
|
2686
|
+
semver@^6.1.2, semver@^6.3.0:
|
2687
|
+
version "6.3.1"
|
2688
|
+
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
|
2689
|
+
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
|
2645
2690
|
|
2646
2691
|
serialize-javascript@3.0.0:
|
2647
2692
|
version "3.0.0"
|
@@ -2736,11 +2781,6 @@ source-map@^0.6.0, source-map@^0.6.1:
|
|
2736
2781
|
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
2737
2782
|
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
2738
2783
|
|
2739
|
-
source-map@~0.7.2:
|
2740
|
-
version "0.7.3"
|
2741
|
-
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
|
2742
|
-
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
|
2743
|
-
|
2744
2784
|
sourcemap-codec@^1.4.8:
|
2745
2785
|
version "1.4.8"
|
2746
2786
|
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
|
@@ -2925,13 +2965,13 @@ table@^5.2.3:
|
|
2925
2965
|
string-width "^3.0.0"
|
2926
2966
|
|
2927
2967
|
terser@^5.0.0:
|
2928
|
-
version "5.
|
2929
|
-
resolved "https://registry.yarnpkg.com/terser/-/terser-5.
|
2930
|
-
integrity sha512-
|
2968
|
+
version "5.19.4"
|
2969
|
+
resolved "https://registry.yarnpkg.com/terser/-/terser-5.19.4.tgz#941426fa482bf9b40a0308ab2b3cd0cf7c775ebd"
|
2970
|
+
integrity sha512-6p1DjHeuluwxDXcuT9VR8p64klWJKo1ILiy19s6C9+0Bh2+NWTX6nD9EPppiER4ICkHDVB1RkVpin/YW2nQn/g==
|
2931
2971
|
dependencies:
|
2932
|
-
|
2972
|
+
"@jridgewell/source-map" "^0.3.3"
|
2973
|
+
acorn "^8.8.2"
|
2933
2974
|
commander "^2.20.0"
|
2934
|
-
source-map "~0.7.2"
|
2935
2975
|
source-map-support "~0.5.20"
|
2936
2976
|
|
2937
2977
|
text-table@^0.2.0:
|
@@ -3150,9 +3190,9 @@ wide-align@1.1.3:
|
|
3150
3190
|
string-width "^1.0.2 || 2"
|
3151
3191
|
|
3152
3192
|
word-wrap@~1.2.3:
|
3153
|
-
version "1.2.
|
3154
|
-
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.
|
3155
|
-
integrity sha512-
|
3193
|
+
version "1.2.5"
|
3194
|
+
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
|
3195
|
+
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
|
3156
3196
|
|
3157
3197
|
wordwrap@^1.0.0:
|
3158
3198
|
version "1.0.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: futurism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Rubisch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '13.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.12.2
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.12.2
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: nokogiri
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,6 +174,7 @@ files:
|
|
188
174
|
- lib/futurism/message_verifier.rb
|
189
175
|
- lib/futurism/options_transformer.rb
|
190
176
|
- lib/futurism/resolver/controller.rb
|
177
|
+
- lib/futurism/resolver/controller/instrumentation.rb
|
191
178
|
- lib/futurism/resolver/controller/renderer.rb
|
192
179
|
- lib/futurism/resolver/resources.rb
|
193
180
|
- lib/futurism/shims/deep_transform_values.rb
|
@@ -196,44 +183,6 @@ files:
|
|
196
183
|
- package.json~
|
197
184
|
- rollup.config.js
|
198
185
|
- rollup.config.js~
|
199
|
-
- test/cable/channel_test.rb
|
200
|
-
- test/dummy/app/channels/application_cable/channel.rb
|
201
|
-
- test/dummy/app/channels/application_cable/connection.rb
|
202
|
-
- test/dummy/app/controllers/application_controller.rb
|
203
|
-
- test/dummy/app/controllers/home_controller.rb
|
204
|
-
- test/dummy/app/controllers/posts_controller.rb
|
205
|
-
- test/dummy/app/helpers/application_helper.rb
|
206
|
-
- test/dummy/app/helpers/posts_helper.rb
|
207
|
-
- test/dummy/app/jobs/application_job.rb
|
208
|
-
- test/dummy/app/models/action_item.rb
|
209
|
-
- test/dummy/app/models/application_record.rb
|
210
|
-
- test/dummy/app/models/post.rb
|
211
|
-
- test/dummy/config/application.rb
|
212
|
-
- test/dummy/config/boot.rb
|
213
|
-
- test/dummy/config/environment.rb
|
214
|
-
- test/dummy/config/environments/development.rb
|
215
|
-
- test/dummy/config/environments/production.rb
|
216
|
-
- test/dummy/config/environments/test.rb
|
217
|
-
- test/dummy/config/initializers/application_controller_renderer.rb
|
218
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
219
|
-
- test/dummy/config/initializers/content_security_policy.rb
|
220
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
221
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
222
|
-
- test/dummy/config/initializers/inflections.rb
|
223
|
-
- test/dummy/config/initializers/mime_types.rb
|
224
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
225
|
-
- test/dummy/config/puma.rb
|
226
|
-
- test/dummy/config/routes.rb
|
227
|
-
- test/dummy/config/spring.rb
|
228
|
-
- test/dummy/db/migrate/20200711122838_create_posts.rb
|
229
|
-
- test/dummy/db/migrate/2021042923813_create_action_items.rb
|
230
|
-
- test/dummy/db/schema.rb
|
231
|
-
- test/futurism_test.rb
|
232
|
-
- test/helper/helper_test.rb
|
233
|
-
- test/integration/navigation_test.rb
|
234
|
-
- test/resolver/controller/renderer_test.rb
|
235
|
-
- test/resolver/controller_test.rb
|
236
|
-
- test/test_helper.rb
|
237
186
|
- yarn.lock
|
238
187
|
homepage: https://github.com/stimulusreflex/futurism
|
239
188
|
licenses:
|
@@ -254,46 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
203
|
- !ruby/object:Gem::Version
|
255
204
|
version: '0'
|
256
205
|
requirements: []
|
257
|
-
rubygems_version: 3.
|
206
|
+
rubygems_version: 3.4.19
|
258
207
|
signing_key:
|
259
208
|
specification_version: 4
|
260
209
|
summary: Lazy-load Rails partials via CableReady
|
261
|
-
test_files:
|
262
|
-
- test/cable/channel_test.rb
|
263
|
-
- test/dummy/app/channels/application_cable/channel.rb
|
264
|
-
- test/dummy/app/channels/application_cable/connection.rb
|
265
|
-
- test/dummy/app/controllers/application_controller.rb
|
266
|
-
- test/dummy/app/controllers/home_controller.rb
|
267
|
-
- test/dummy/app/controllers/posts_controller.rb
|
268
|
-
- test/dummy/app/helpers/application_helper.rb
|
269
|
-
- test/dummy/app/helpers/posts_helper.rb
|
270
|
-
- test/dummy/app/jobs/application_job.rb
|
271
|
-
- test/dummy/app/models/action_item.rb
|
272
|
-
- test/dummy/app/models/application_record.rb
|
273
|
-
- test/dummy/app/models/post.rb
|
274
|
-
- test/dummy/config/application.rb
|
275
|
-
- test/dummy/config/boot.rb
|
276
|
-
- test/dummy/config/environment.rb
|
277
|
-
- test/dummy/config/environments/development.rb
|
278
|
-
- test/dummy/config/environments/production.rb
|
279
|
-
- test/dummy/config/environments/test.rb
|
280
|
-
- test/dummy/config/initializers/application_controller_renderer.rb
|
281
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
282
|
-
- test/dummy/config/initializers/content_security_policy.rb
|
283
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
284
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
285
|
-
- test/dummy/config/initializers/inflections.rb
|
286
|
-
- test/dummy/config/initializers/mime_types.rb
|
287
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
288
|
-
- test/dummy/config/puma.rb
|
289
|
-
- test/dummy/config/routes.rb
|
290
|
-
- test/dummy/config/spring.rb
|
291
|
-
- test/dummy/db/migrate/20200711122838_create_posts.rb
|
292
|
-
- test/dummy/db/migrate/2021042923813_create_action_items.rb
|
293
|
-
- test/dummy/db/schema.rb
|
294
|
-
- test/futurism_test.rb
|
295
|
-
- test/helper/helper_test.rb
|
296
|
-
- test/integration/navigation_test.rb
|
297
|
-
- test/resolver/controller/renderer_test.rb
|
298
|
-
- test/resolver/controller_test.rb
|
299
|
-
- test/test_helper.rb
|
210
|
+
test_files: []
|
data/test/cable/channel_test.rb
DELETED
@@ -1,319 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
def with_mocked_renderer
|
4
|
-
renderer = Minitest::Mock.new
|
5
|
-
|
6
|
-
Futurism::Resolver::Controller::Renderer.stub(:for, renderer) do
|
7
|
-
yield(renderer)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def with_mocked_cable_ready
|
12
|
-
cable_ready_mock = MiniTest::Mock.new
|
13
|
-
cable_ready_channel = MiniTest::Mock.new
|
14
|
-
cable_ready_channel.expect(:outer_html, nil, [Hash])
|
15
|
-
cable_ready_channel.expect(:outer_html, nil, [Hash])
|
16
|
-
|
17
|
-
cable_ready_mock.expect(:[], cable_ready_channel, ["1"])
|
18
|
-
cable_ready_mock.expect(:[], cable_ready_channel, ["1"])
|
19
|
-
cable_ready_mock.expect(:broadcast, nil)
|
20
|
-
cable_ready_mock.expect(:broadcast, nil)
|
21
|
-
cable_ready_mock.expect(:broadcast, nil)
|
22
|
-
|
23
|
-
CableReady::Broadcaster.alias_method(:orig_cable_ready, :cable_ready)
|
24
|
-
|
25
|
-
CableReady::Broadcaster.define_method(:cable_ready) do
|
26
|
-
cable_ready_mock
|
27
|
-
end
|
28
|
-
|
29
|
-
yield cable_ready_mock
|
30
|
-
|
31
|
-
CableReady::Broadcaster.undef_method(:cable_ready)
|
32
|
-
|
33
|
-
CableReady::Broadcaster.alias_method(:cable_ready, :orig_cable_ready)
|
34
|
-
end
|
35
|
-
|
36
|
-
class Futurism::ChannelTest < ActionCable::Channel::TestCase
|
37
|
-
include Futurism::Helpers
|
38
|
-
include ActionView::Helpers
|
39
|
-
include ActionView::Context
|
40
|
-
include CableReady::Broadcaster
|
41
|
-
|
42
|
-
setup do
|
43
|
-
stub_connection(env: {"SCRIPT_NAME" => "/cable"}, identifiers: [:current_user], current_user: Struct.new(:id)[1])
|
44
|
-
end
|
45
|
-
|
46
|
-
test "subscribed" do
|
47
|
-
subscribe(channel: "Futurism::Channel")
|
48
|
-
|
49
|
-
assert subscription.confirmed?
|
50
|
-
|
51
|
-
assert_has_stream "Futurism::Channel:1"
|
52
|
-
end
|
53
|
-
|
54
|
-
test "broadcasts a rendered model after receiving signed params" do
|
55
|
-
with_mocked_renderer do |mock_renderer|
|
56
|
-
post = Post.create title: "Lorem"
|
57
|
-
fragment = Nokogiri::HTML.fragment(futurize(post) {})
|
58
|
-
signed_params_array = fragment.children.map { |element| element["data-signed-params"] }
|
59
|
-
sgids = fragment.children.map { |element| element["data-sgid"] }
|
60
|
-
subscribe
|
61
|
-
|
62
|
-
mock_renderer.expect :render, "<tag></tag>", [post]
|
63
|
-
|
64
|
-
perform :receive, {"signed_params" => signed_params_array, "sgids" => sgids}
|
65
|
-
|
66
|
-
assert_mock mock_renderer
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
test "broadcasts an ActiveRecord::Relation" do
|
71
|
-
with_mocked_renderer do |mock_renderer|
|
72
|
-
post1 = Post.create(title: "Lorem")
|
73
|
-
post2 = Post.create(title: "Ipsum")
|
74
|
-
|
75
|
-
fragment = Nokogiri::HTML.fragment(futurize(Post.all) {})
|
76
|
-
signed_params_array = fragment.children.map { |element| element["data-signed-params"] }
|
77
|
-
sgids = fragment.children.map { |element| element["data-sgid"] }
|
78
|
-
subscribe
|
79
|
-
|
80
|
-
mock_renderer
|
81
|
-
.expect(:render, "<tag></tag>", [post1])
|
82
|
-
.expect :render, "<tag></tag>", [post2]
|
83
|
-
|
84
|
-
perform :receive, {"signed_params" => signed_params_array, "sgids" => sgids}
|
85
|
-
|
86
|
-
assert_mock mock_renderer
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
test "broadcasts a rendered partial after receiving signed params" do
|
91
|
-
with_mocked_renderer do |mock_renderer|
|
92
|
-
post = Post.create title: "Lorem"
|
93
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", locals: {post: post}) {})
|
94
|
-
signed_params = fragment.children.first["data-signed-params"]
|
95
|
-
subscribe
|
96
|
-
|
97
|
-
mock_renderer
|
98
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: post}])
|
99
|
-
|
100
|
-
perform :receive, {"signed_params" => [signed_params]}
|
101
|
-
|
102
|
-
assert_mock mock_renderer
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
test "broadcasts a rendered partial after receiving the shorthand syntax" do
|
107
|
-
with_mocked_renderer do |mock_renderer|
|
108
|
-
post = Post.create title: "Lorem"
|
109
|
-
fragment = Nokogiri::HTML.fragment(futurize("posts/card", post: post) {})
|
110
|
-
signed_params = fragment.children.first["data-signed-params"]
|
111
|
-
subscribe
|
112
|
-
|
113
|
-
mock_renderer.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: post}])
|
114
|
-
perform :receive, {"signed_params" => [signed_params]}
|
115
|
-
|
116
|
-
assert_mock mock_renderer
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
test "broadcasts a rendered partial after receiving the shorthand syntax with html options" do
|
121
|
-
with_mocked_renderer do |mock_renderer|
|
122
|
-
post = Post.create title: "Lorem"
|
123
|
-
fragment = Nokogiri::HTML.fragment(futurize("posts/card", post: post, html_options: {style: "color: green"}) {})
|
124
|
-
signed_params = fragment.children.first["data-signed-params"]
|
125
|
-
subscribe
|
126
|
-
|
127
|
-
mock_renderer.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: post}])
|
128
|
-
|
129
|
-
perform :receive, {"signed_params" => [signed_params]}
|
130
|
-
|
131
|
-
assert_mock mock_renderer
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
test "broadcasts a collection" do
|
136
|
-
with_mocked_renderer do |mock_renderer|
|
137
|
-
Post.create title: "Lorem"
|
138
|
-
Post.create title: "Ipsum"
|
139
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: Post.all, locals: {important_local: "needed to render"}) {})
|
140
|
-
subscribe
|
141
|
-
|
142
|
-
mock_renderer
|
143
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: Post.first, important_local: "needed to render", post_counter: 0}])
|
144
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: Post.last, important_local: "needed to render", post_counter: 1}])
|
145
|
-
|
146
|
-
signed_params = fragment.children.first["data-signed-params"]
|
147
|
-
perform :receive, {"signed_params" => [signed_params]}
|
148
|
-
|
149
|
-
signed_params = fragment.children.last["data-signed-params"]
|
150
|
-
perform :receive, {"signed_params" => [signed_params]}
|
151
|
-
|
152
|
-
assert_mock mock_renderer
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
test "broadcasts a collection (with multi-word class)" do
|
157
|
-
with_mocked_renderer do |mock_renderer|
|
158
|
-
ActionItem.create description: "Do this"
|
159
|
-
ActionItem.create description: "Do that"
|
160
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: ActionItem.all, locals: {important_local: "needed to render"}) {})
|
161
|
-
|
162
|
-
subscribe
|
163
|
-
|
164
|
-
mock_renderer
|
165
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {action_item: ActionItem.first, important_local: "needed to render", action_item_counter: 0}])
|
166
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {action_item: ActionItem.last, important_local: "needed to render", action_item_counter: 1}])
|
167
|
-
|
168
|
-
signed_params = fragment.children.first["data-signed-params"]
|
169
|
-
perform :receive, {"signed_params" => [signed_params]}
|
170
|
-
|
171
|
-
signed_params = fragment.children.last["data-signed-params"]
|
172
|
-
perform :receive, {"signed_params" => [signed_params]}
|
173
|
-
|
174
|
-
assert_mock mock_renderer
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
test "broadcasts a collection with :as" do
|
179
|
-
with_mocked_renderer do |mock_renderer|
|
180
|
-
Post.create title: "Lorem"
|
181
|
-
Post.create title: "Ipsum"
|
182
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: Post.all, as: :post_item) {})
|
183
|
-
subscribe
|
184
|
-
|
185
|
-
mock_renderer.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post_item: Post.first, post_item_counter: 0}])
|
186
|
-
signed_params = fragment.children.first["data-signed-params"]
|
187
|
-
perform :receive, {"signed_params" => [signed_params]}
|
188
|
-
|
189
|
-
mock_renderer.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post_item: Post.last, post_item_counter: 1}])
|
190
|
-
signed_params = fragment.children.last["data-signed-params"]
|
191
|
-
perform :receive, {"signed_params" => [signed_params]}
|
192
|
-
|
193
|
-
assert_mock mock_renderer
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
test "broadcasts elements of a collection immediately" do
|
198
|
-
with_mocked_cable_ready do |cable_ready_mock|
|
199
|
-
Post.create title: "Lorem"
|
200
|
-
Post.create title: "Ipsum"
|
201
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: Post.all, broadcast_each: true, locals: {important_local: "needed to render"}) {})
|
202
|
-
subscribe
|
203
|
-
|
204
|
-
signed_params_1 = fragment.children.first["data-signed-params"]
|
205
|
-
broadcast_each_1 = fragment.children.first["data-broadcast-each"]
|
206
|
-
signed_params_2 = fragment.children.last["data-signed-params"]
|
207
|
-
broadcast_each_2 = fragment.children.last["data-broadcast-each"]
|
208
|
-
perform :receive, {"signed_params" => [signed_params_1, signed_params_2], "broadcast_each" => [broadcast_each_1, broadcast_each_2]}
|
209
|
-
|
210
|
-
assert_mock cable_ready_mock
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
test "broadcasts an inline rendered text" do
|
215
|
-
fragment = Nokogiri::HTML.fragment(futurize(inline: "<%= 1 + 2 %>") {})
|
216
|
-
signed_params = fragment.children.first["data-signed-params"]
|
217
|
-
subscribe(channel: "Futurism::Channel")
|
218
|
-
|
219
|
-
assert_cable_ready_operation_on("Futurism::Channel:1", operation: "outerHtml", selector: "[data-signed-params='#{signed_params}']", html: "3") do
|
220
|
-
perform :receive, {"signed_params" => [signed_params]}
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
test "broadcasts a correctly formed path" do
|
225
|
-
post = Post.create title: "Lorem"
|
226
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", locals: {post: post}) {})
|
227
|
-
signed_params = fragment.children.first["data-signed-params"]
|
228
|
-
subscribe(channel: "Futurism::Channel")
|
229
|
-
|
230
|
-
assert_cable_ready_operation_on("Futurism::Channel:1", operation: "outerHtml",
|
231
|
-
selector: "[data-signed-params='#{signed_params}']",
|
232
|
-
html: "<div class=\"card\">\n Lorem\n <a href=\"/posts/1/edit\">Edit</a>\n</div>\n") do
|
233
|
-
perform :receive, {"signed_params" => [signed_params]}
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
test "passes parsed params to controller render" do
|
238
|
-
with_mocked_renderer do |mock_renderer|
|
239
|
-
post = Post.create title: "Lorem"
|
240
|
-
fragment = Nokogiri::HTML.fragment(futurize(post) {})
|
241
|
-
signed_params_array = fragment.children.map { |element| element["data-signed-params"] }
|
242
|
-
sgids = fragment.children.map { |element| element["data-sgid"] }
|
243
|
-
urls = Array.new(fragment.children.length, "http://www.example.org/route?param1=true¶m2=1234")
|
244
|
-
subscribe
|
245
|
-
|
246
|
-
mock_renderer.expect(:render, "<tag></tag>", [post])
|
247
|
-
|
248
|
-
perform :receive, {"signed_params" => signed_params_array, "sgids" => sgids, "urls" => urls}
|
249
|
-
|
250
|
-
assert_mock mock_renderer
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
test "renders error message when rendering invalid partial error" do
|
255
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "INVALID/PARTIAL") {})
|
256
|
-
signed_params = fragment.children.first["data-signed-params"]
|
257
|
-
subscribe(channel: "Futurism::Channel")
|
258
|
-
|
259
|
-
assert_cable_ready_operation_on("Futurism::Channel:1", operation: "outerHtml",
|
260
|
-
selector: "[data-signed-params='#{signed_params}']",
|
261
|
-
html: /Missing partial INVALID\/_PARTIAL/) do
|
262
|
-
perform :receive, {"signed_params" => [signed_params]}
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
test "renders error message when wrong variable name" do
|
267
|
-
Post.create title: "Lorem"
|
268
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: Post.all, as: :wrong_variable_name) {})
|
269
|
-
signed_params = fragment.children.first["data-signed-params"]
|
270
|
-
subscribe(channel: "Futurism::Channel")
|
271
|
-
|
272
|
-
assert_cable_ready_operation_on("Futurism::Channel:1", operation: "outerHtml",
|
273
|
-
selector: "[data-signed-params='#{signed_params}']",
|
274
|
-
html: /undefined local variable or method/) do
|
275
|
-
perform :receive, {"signed_params" => [signed_params]}
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
def assert_cable_ready_operation_on(stream, operation:, selector:, html:, &block)
|
280
|
-
data = {
|
281
|
-
"cableReady" => true,
|
282
|
-
"operations" => [{
|
283
|
-
"selector" => selector,
|
284
|
-
"html" => html,
|
285
|
-
"operation" => operation
|
286
|
-
}]
|
287
|
-
}
|
288
|
-
|
289
|
-
old_messages = broadcasts(stream)
|
290
|
-
clear_messages(stream)
|
291
|
-
|
292
|
-
assert_nothing_raised(&block)
|
293
|
-
|
294
|
-
new_messages = broadcasts(stream)
|
295
|
-
clear_messages(stream)
|
296
|
-
|
297
|
-
# Restore all sent messages
|
298
|
-
(old_messages + new_messages).each { |m| pubsub_adapter.broadcast(stream, m) }
|
299
|
-
|
300
|
-
message = new_messages.find { |msg| cable_ready_match?(ActiveSupport::JSON.decode(msg), data) }
|
301
|
-
|
302
|
-
assert message, "No messages sent with #{data} to #{stream}"
|
303
|
-
end
|
304
|
-
|
305
|
-
def cable_ready_match?(message, matcher)
|
306
|
-
return true if message == matcher
|
307
|
-
|
308
|
-
first_matching_operation = ["operations", 0]
|
309
|
-
|
310
|
-
matcher_operation = matcher.dig(*first_matching_operation)
|
311
|
-
message_operation = message.dig(*first_matching_operation)
|
312
|
-
|
313
|
-
message.dig("cableReady") == true &&
|
314
|
-
(matcher_operation.dig("selector") === message_operation.dig("selector") ||
|
315
|
-
matcher_operation.dig("selector").match(message_operation.dig("selector"))) &&
|
316
|
-
(matcher_operation.dig("html") === message_operation.dig("html") ||
|
317
|
-
matcher_operation.dig("html").match(message_operation.dig("html")))
|
318
|
-
end
|
319
|
-
end
|