Project

General

Profile

Actions

Patch #29632

closed

Redmine::SortCriteria#normalize! does not limit properly the number of elements

Added by Mizuki ISHIKAWA over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Only three sorting criteria can be selected on the query edit screen.
With code before r16390, only three items could be saved as data according to screen specifications.

However, since "slice(0,3)" was changed to "slice!(3)" at r16390, the following result is returned now.

# slice(0,3)
sort_criteria = [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc'], ['id', 'asc'], ['project', 'asc'], ['subject', 'asc']]
p sort_criteria.slice(0,3)
=> [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc']]

# slice!(3)
# The number limit is not made
sort_criteria .slice!(3)
p sort_criteria 
=> [['priority', 'desc'], ['tracker', 'asc'], ['priority', 'asc'], ['subject', 'asc']]


I think it should be restricted to only three from the beginning like the case of "slice(0, 3)".
The attached file is a patch for fix.

Files

Actions

Also available in: Atom PDF