view_component 3.0.0.rc3 → 3.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/docs/CHANGELOG.md +8 -0
- data/lib/view_component/test_helpers.rb +29 -18
- data/lib/view_component/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53d058ef489a0f7230b3a83fe92d36fab42b9b8ccf0cd2bba0d12f7320f2c261
|
4
|
+
data.tar.gz: de28dc5a7e3e9c34c3cf81bbd5d52f518c653950552547c86a547bb4a577bdfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6161e41e5b9b82ce20f9ffc624cfe2910e707d867e2ba0019bc960a02353e7d2b083700e3504ea1f84da83f9a31110eb581a07a16609d30c6a7737806f5986e
|
7
|
+
data.tar.gz: c137ce79675ec78c4f31dff419b42fdf31d2af696e2275047d74058c7e1402be00e0e44df125ea6c5803b59e6931d8a7619c9c266376b02881965a778e60d784
|
data/docs/CHANGELOG.md
CHANGED
@@ -10,6 +10,14 @@ nav_order: 5
|
|
10
10
|
|
11
11
|
## main
|
12
12
|
|
13
|
+
## v3.0.0.rc4
|
14
|
+
|
15
|
+
Run into an issue with this release candidate? [Let us know](https://github.com/ViewComponent/view_component/issues/1629).
|
16
|
+
|
17
|
+
* Add `TestHelpers#vc_test_request`.
|
18
|
+
|
19
|
+
*Joel Hawksley*
|
20
|
+
|
13
21
|
## v3.0.0.rc3
|
14
22
|
|
15
23
|
Run into an issue with this release candidate? [Let us know](https://github.com/ViewComponent/view_component/issues/1629).
|
@@ -157,23 +157,23 @@ module ViewComponent
|
|
157
157
|
#
|
158
158
|
# @param path [String] The path to set for the current request.
|
159
159
|
def with_request_url(path)
|
160
|
-
old_request_path_info =
|
161
|
-
old_request_path_parameters =
|
162
|
-
old_request_query_parameters =
|
163
|
-
old_request_query_string =
|
160
|
+
old_request_path_info = vc_test_request.path_info
|
161
|
+
old_request_path_parameters = vc_test_request.path_parameters
|
162
|
+
old_request_query_parameters = vc_test_request.query_parameters
|
163
|
+
old_request_query_string = vc_test_request.query_string
|
164
164
|
old_controller = defined?(@vc_test_controller) && @vc_test_controller
|
165
165
|
|
166
166
|
path, query = path.split("?", 2)
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
167
|
+
vc_test_request.path_info = path
|
168
|
+
vc_test_request.path_parameters = Rails.application.routes.recognize_path_with_request(vc_test_request, path, {})
|
169
|
+
vc_test_request.set_header("action_dispatch.request.query_parameters", Rack::Utils.parse_nested_query(query))
|
170
|
+
vc_test_request.set_header(Rack::QUERY_STRING, query)
|
171
171
|
yield
|
172
172
|
ensure
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
173
|
+
vc_test_request.path_info = old_request_path_info
|
174
|
+
vc_test_request.path_parameters = old_request_path_parameters
|
175
|
+
vc_test_request.set_header("action_dispatch.request.query_parameters", old_request_query_parameters)
|
176
|
+
vc_test_request.set_header(Rack::QUERY_STRING, old_request_query_string)
|
177
177
|
@vc_test_controller = old_controller
|
178
178
|
end
|
179
179
|
|
@@ -192,11 +192,19 @@ module ViewComponent
|
|
192
192
|
@vc_test_controller ||= __vc_test_helpers_build_controller(Base.test_controller.constantize)
|
193
193
|
end
|
194
194
|
|
195
|
-
#
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
195
|
+
# Access the request used by `render_inline`:
|
196
|
+
#
|
197
|
+
# ```ruby
|
198
|
+
# test "component does not render in Firefox" do
|
199
|
+
# request.env["HTTP_USER_AGENT"] = "Mozilla/5.0"
|
200
|
+
# render_inline(NoFirefoxComponent.new)
|
201
|
+
# refute_component_rendered
|
202
|
+
# end
|
203
|
+
# ```
|
204
|
+
#
|
205
|
+
# @return [ActionDispatch::TestRequest]
|
206
|
+
def vc_test_request
|
207
|
+
@vc_test_request ||=
|
200
208
|
begin
|
201
209
|
out = ActionDispatch::TestRequest.create
|
202
210
|
out.session = ActionController::TestSession.new
|
@@ -204,8 +212,11 @@ module ViewComponent
|
|
204
212
|
end
|
205
213
|
end
|
206
214
|
|
215
|
+
# Note: We prefix private methods here to prevent collisions in consumer's tests.
|
216
|
+
private
|
217
|
+
|
207
218
|
def __vc_test_helpers_build_controller(klass)
|
208
|
-
klass.new.tap { |c| c.request =
|
219
|
+
klass.new.tap { |c| c.request = vc_test_request }.extend(Rails.application.routes.url_helpers)
|
209
220
|
end
|
210
221
|
|
211
222
|
def __vc_test_helpers_preview_class
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ViewComponent Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|