Defect #43524 » patch-issue-43524-fix-project-sort-by-parent-v2.diff
| app/models/project_query.rb | ||
|---|---|---|
|
QueryColumn.new(:short_description, :sortable => "#{Project.table_name}.description", :caption => :field_description),
|
||
|
QueryColumn.new(:homepage, :sortable => "#{Project.table_name}.homepage"),
|
||
|
QueryColumn.new(:identifier, :sortable => "#{Project.table_name}.identifier"),
|
||
|
QueryColumn.new(:parent_id, :sortable => "#{Project.table_name}.lft ASC", :default_order => 'desc', :caption => :field_parent),
|
||
|
QueryColumn.new(:parent_id, :sortable => "#{Project.table_name}.lft", :default_order => 'asc', :caption => :field_parent),
|
||
|
QueryColumn.new(:is_public, :sortable => "#{Project.table_name}.is_public", :groupable => true),
|
||
|
QueryColumn.new(:created_on, :sortable => "#{Project.table_name}.created_on", :default_order => 'desc'),
|
||
|
QueryColumn.new(:updated_on, :sortable => "#{Project.table_name}.updated_on", :default_order => 'desc'),
|
||
| test/functional/projects_controller_test.rb | ||
|---|---|---|
|
@request.session[:user_id] = 1
|
||
|
get :index, :params => {
|
||
|
:c => ['name', 'short_description'],
|
||
|
:sort => 'parent_id:desc,lft:desc',
|
||
|
:sort => 'parent_id:asc',
|
||
|
:display_type => 'list'
|
||
|
}
|
||
|
assert_response :success
|
||
| test/unit/project_query_test.rb | ||
|---|---|---|
|
assert_equal scope_without, scope_with
|
||
|
end
|
||
|
end
|
||
|
def test_sort_by_parent_id_asc_should_apply_asc_direction
|
||
|
q = ProjectQuery.new
|
||
|
q.sort_criteria = [['parent_id', 'asc']]
|
||
|
sort_clause = q.sort_clause
|
||
|
assert_not_nil sort_clause
|
||
|
joined = sort_clause.map(&:to_s).join(' ')
|
||
|
# sort clause must use lft with ASC (user-chosen direction), not a hardcoded lft ASC
|
||
|
assert_match(/lft ASC/i, joined)
|
||
|
assert_no_match(/lft DESC/i, joined)
|
||
|
end
|
||
|
def test_sort_by_parent_id_desc_should_apply_desc_direction
|
||
|
q = ProjectQuery.new
|
||
|
q.sort_criteria = [['parent_id', 'desc']]
|
||
|
sort_clause = q.sort_clause
|
||
|
assert_not_nil sort_clause
|
||
|
joined = sort_clause.map(&:to_s).join(' ')
|
||
|
# DESC direction must be applied (previously it was always fixed to ASC via lft ASC)
|
||
|
assert_match(/lft DESC/i, joined)
|
||
|
assert_no_match(/lft ASC/i, joined)
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- …
- 4
- 5
- 6
- Next »