-
Notifications
You must be signed in to change notification settings - Fork 35
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
Support array query params #234
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,15 @@ class HotwireCombobox::HelperTest < ApplicationViewTestCase | |
assert_attrs html, tag_name: "turbo-frame", src: "/foo?bar=baz&qux=quux&page=2&format=turbo_stream" | ||
end | ||
|
||
test "hw_paginated_combobox_options includes array params" do | ||
request.expects(:path).returns("/foo") | ||
request.expects(:query_parameters).returns({ ary: [ 1, 2 ] }.with_indifferent_access) | ||
|
||
html = hw_paginated_combobox_options [], next_page: 2 | ||
|
||
assert_attrs html, tag_name: "turbo-frame", src: "/foo?ary=1&ary=2&page=2&format=turbo_stream" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As far as I know, Rails prefers the I think to get a passing test using that notation we'd need to unescape the url encoding in the result. Something like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. switched the test to include |
||
end | ||
|
||
test "single repeating character values" do | ||
form = form_with model: OpenStruct.new(run_at: "* * * * *", persisted?: true, model_name: OpenStruct.new(param_key: :foo)), url: "#" do |form| | ||
form.combobox :run_at, [ "@hourly", "@daily", "@weekly", "@monthly", "@every 4h", "0 12 * * *" ], free_text: true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know Rack exposed this util. Nice!
Glancing at Rack's source code, it seems we should use
parse_nested_query
instead. Any reason to preferparse_query
over that?Also, I noticed Rack exposes
build_nested_query
as well. What do you think about using that instead ofURI.encode_www_form
on the next line? Probably a good idea to use the pair together as they'll likely evolve together as well inside Rack.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, makes a lot of sense to use that same setoff parse/build and switched to the nested version.