view_component 3.0.0.rc3 → 3.0.0.rc4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of view_component might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f88375c08b20eb604992d315362fbdf6e0654fd87d7766d1ac404daecb1b57c9
4
- data.tar.gz: 5f37ce63b609f5ff542a7e7c4629c952e3a02fc4e2ffc83df28aee86ff5d40cd
3
+ metadata.gz: 53d058ef489a0f7230b3a83fe92d36fab42b9b8ccf0cd2bba0d12f7320f2c261
4
+ data.tar.gz: de28dc5a7e3e9c34c3cf81bbd5d52f518c653950552547c86a547bb4a577bdfa
5
5
  SHA512:
6
- metadata.gz: 425107ab124527b5199b4174437c17a0f2dae4447b77a9393f68dd8c7a88517e25a3100fa0ed4cf6190d7e3b38390c6fd5cf48718753a53169f72dfe50ae5d12
7
- data.tar.gz: b1642a727d8a586d8dec7a2e7075b570f5ccb20cee0b3c41037ac0b119adc6261ca1d1fb1dea0558f4bb40a0a45ba73b111ce4816a85be6798e3fb2bfaf76daf
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 = __vc_test_helpers_request.path_info
161
- old_request_path_parameters = __vc_test_helpers_request.path_parameters
162
- old_request_query_parameters = __vc_test_helpers_request.query_parameters
163
- old_request_query_string = __vc_test_helpers_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
- __vc_test_helpers_request.path_info = path
168
- __vc_test_helpers_request.path_parameters = Rails.application.routes.recognize_path_with_request(__vc_test_helpers_request, path, {})
169
- __vc_test_helpers_request.set_header("action_dispatch.request.query_parameters", Rack::Utils.parse_nested_query(query))
170
- __vc_test_helpers_request.set_header(Rack::QUERY_STRING, query)
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
- __vc_test_helpers_request.path_info = old_request_path_info
174
- __vc_test_helpers_request.path_parameters = old_request_path_parameters
175
- __vc_test_helpers_request.set_header("action_dispatch.request.query_parameters", old_request_query_parameters)
176
- __vc_test_helpers_request.set_header(Rack::QUERY_STRING, old_request_query_string)
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
- # Note: We prefix private methods here to prevent collisions in consumer's tests.
196
- private
197
-
198
- def __vc_test_helpers_request
199
- @__vc_test_helpers_request ||=
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 = __vc_test_helpers_request }.extend(Rails.application.routes.url_helpers)
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
@@ -5,7 +5,7 @@ module ViewComponent
5
5
  MAJOR = 3
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "rc3"
8
+ PRE = "rc4"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
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.rc3
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-08 00:00:00.000000000 Z
11
+ date: 2023-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport