Actions
Defect #40683
closedInlineAutocompleteSystemTest#test_inline_autocomplete_for_issues_with_double_hash_keep_syntax failure after #40237 fix
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Text formatting
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Affected version:
Description
After #40237 (Error in autocomplete (`ActionController::BadRequest (Invalid query parameters: invalid %-encoding (%)`)
) patch was merged, following #38852 (## issue syntax is not kept when selecting an issue from the inline autocomplete
) patch's system test seems to start failing.
def test_inline_autocomplete_for_issues_with_double_hash_keep_syntax
log_user('admin', 'admin')
visit 'projects/ecookbook/issues/new'
fill_in 'Description', :with => '##Closed'
within('.tribute-container') do
assert page.has_text? 'Bug #12: Closed issue on a locked version'
assert page.has_text? 'Bug #11: Closed issue on a closed version'
assert page.has_text? 'Bug #8: Closed issue'
:
Before #40237 fix, controller side couldn't receive after #
parameter in the url,
- JavaScript sends url:
/issues/auto_complete?project_id=ecookbook&q=#Close
- Controller receives url/params:
Started GET "/issues/auto_complete?project_id=ecookbook&q=" for 127.0.0.1 at 2024-05-12 22:41:35 +0900 Processing by AutoCompletesController#issues as */* Parameters: {"project_id"=>"ecookbook", "q"=>""}
#
parameter in the url.
- JavaScript sends url:
/issues/auto_complete?project_id=ecookbook&q=%23Close
- Controller receives url/params:
Started GET "/issues/auto_complete?project_id=ecookbook&q=%23Close" for 127.0.0.1 at 2024-05-12 22:41:54 +0900 Processing by AutoCompletesController#issues as */* Parameters: {"project_id"=>"ecookbook", "q"=>"#Close"}
Then, querying #Close
returns nothing (empty array) because there is no issues which include whole words.
https://www.redmine.org/projects/redmine/repository/svn/entry/trunk/app/controllers/auto_completes_controller.rb#L32
:
if q.present?
if q =~ /\A#?(\d+)\z/
issues << scope.find_by(:id => $1.to_i)
end
issues += scope.like(q).order(:id => :desc).limit(10).to_a
issues.compact!
else
issues += scope.order(:id => :desc).limit(10).to_a
end
:
I think that just system test side input/output adjustment is enough (to pass above regexp (/\A#?(\d+)\z/
) part code), but I am not sure whether this is correct solution, so someone reviewing this is helpful.
--- a/test/system/inline_autocomplete_test.rb
+++ b/test/system/inline_autocomplete_test.rb
@@ -47,12 +47,10 @@ class InlineAutocompleteSystemTest < ApplicationSystemTestCase
log_user('admin', 'admin')
visit 'projects/ecookbook/issues/new'
- fill_in 'Description', :with => '##Closed'
+ fill_in 'Description', :with => '##12'
within('.tribute-container') do
assert page.has_text? 'Bug #12: Closed issue on a locked version'
- assert page.has_text? 'Bug #11: Closed issue on a closed version'
- assert page.has_text? 'Bug #8: Closed issue'
first('li').click
end
Files
Related issues
Actions