Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #with_request_url to ensure request.query_parameters is an instance of ActiveSupport::HashWithIndifferentAccess #1833

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ nav_order: 5

*Sebastjan Prachovskij*

* Fix `#with_request_url` to ensure `request.query_parameters` is an instance of ActiveSupport::HashWithIndifferentAccess.

*milk1000cc*

## 3.5.0

* Add Skroutz to users list.
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ ViewComponent is built by over a hundred members of the community, including:
<img src="https://avatars.githubusercontent.com/nickmalcolm?s=64" alt="nickmalcolm" width="32" />
<img src="https://avatars.githubusercontent.com/reeganviljoen?s=64" alt="reeganviljoen" width="32" />
<img src="https://avatars.githubusercontent.com/thomascchen?s=64" alt="thomascchen" width="32" />
<img src="https://avatars.githubusercontent.com/milk1000cc?s=64" alt="milk1000cc" width="32" />

## Who uses ViewComponent?

Expand Down
3 changes: 2 additions & 1 deletion lib/view_component/test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def with_request_url(path, host: nil)
vc_test_request.host = host if host
vc_test_request.path_info = path
vc_test_request.path_parameters = Rails.application.routes.recognize_path_with_request(vc_test_request, path, {})
vc_test_request.set_header("action_dispatch.request.query_parameters", Rack::Utils.parse_nested_query(query))
vc_test_request.set_header("action_dispatch.request.query_parameters",
Rack::Utils.parse_nested_query(query).with_indifferent_access)
vc_test_request.set_header(Rack::QUERY_STRING, query)
yield
ensure
Expand Down
1 change: 1 addition & 0 deletions test/sandbox/test/rendering_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ def test_with_request_url_with_query_parameters
assert_equal "/products", vc_test_request.path
assert_equal "mykey=myvalue&otherkey=othervalue", vc_test_request.query_string
assert_equal "/products?mykey=myvalue&otherkey=othervalue", vc_test_request.fullpath
assert_instance_of ActiveSupport::HashWithIndifferentAccess, vc_test_request.query_parameters
end

with_request_url "/products?mykey[mynestedkey]=myvalue" do
Expand Down
Loading