Enter a search term for a field (e.g. title=cheese) and submit
Click "More Options" to return to Advanced search page, which will be prepopulated
Change "cheese" to "bread" and submit
URL query string will have title=cheese&title=bread in it
Oddly, it's the 2nd "correct" param that gets used by the search code, so this doesn't actually result in corrupted behavior, only a confusing incorrect URL.
The underlying problem is that while #advanced_search_state excludes search fields from the hidden form inputs that are generated, it's wrapped in a call to search_state.params_for_search which adds them back in. So I've removed that call.
Note that the 2nd test case I added actually passes even without this fix, because capybara's rack_test driver uses only the text input, instead of using both the hidden and text input, which real browsers do. But I've included the test anyway, for completeness. To see the bug in action in a real browser, you can run through the steps above on the code in this repo: https://github.com/codeforkjeff/advanced_search_bug
This fixes the following bug:
Oddly, it's the 2nd "correct" param that gets used by the search code, so this doesn't actually result in corrupted behavior, only a confusing incorrect URL.
The underlying problem is that while
#advanced_search_state
excludes search fields from the hidden form inputs that are generated, it's wrapped in a call tosearch_state.params_for_search
which adds them back in. So I've removed that call.Note that the 2nd test case I added actually passes even without this fix, because capybara's rack_test driver uses only the text input, instead of using both the hidden and text input, which real browsers do. But I've included the test anyway, for completeness. To see the bug in action in a real browser, you can run through the steps above on the code in this repo: https://github.com/codeforkjeff/advanced_search_bug