Defect #43524 » patch-issue-43524-fix-project-sort-by-parent-v2.diff
| app/models/project_query.rb | ||
|---|---|---|
| 39 | 39 |
QueryColumn.new(:short_description, :sortable => "#{Project.table_name}.description", :caption => :field_description),
|
| 40 | 40 |
QueryColumn.new(:homepage, :sortable => "#{Project.table_name}.homepage"),
|
| 41 | 41 |
QueryColumn.new(:identifier, :sortable => "#{Project.table_name}.identifier"),
|
| 42 |
QueryColumn.new(:parent_id, :sortable => "#{Project.table_name}.lft ASC", :default_order => 'desc', :caption => :field_parent),
|
|
| 42 |
QueryColumn.new(:parent_id, :sortable => "#{Project.table_name}.lft", :default_order => 'asc', :caption => :field_parent),
|
|
| 43 | 43 |
QueryColumn.new(:is_public, :sortable => "#{Project.table_name}.is_public", :groupable => true),
|
| 44 | 44 |
QueryColumn.new(:created_on, :sortable => "#{Project.table_name}.created_on", :default_order => 'desc'),
|
| 45 | 45 |
QueryColumn.new(:updated_on, :sortable => "#{Project.table_name}.updated_on", :default_order => 'desc'),
|
| test/functional/projects_controller_test.rb | ||
|---|---|---|
| 129 | 129 |
@request.session[:user_id] = 1 |
| 130 | 130 |
get :index, :params => {
|
| 131 | 131 |
:c => ['name', 'short_description'], |
| 132 |
:sort => 'parent_id:desc,lft:desc',
|
|
| 132 |
:sort => 'parent_id:asc',
|
|
| 133 | 133 |
:display_type => 'list' |
| 134 | 134 |
} |
| 135 | 135 |
assert_response :success |
| test/unit/project_query_test.rb | ||
|---|---|---|
| 141 | 141 |
assert_equal scope_without, scope_with |
| 142 | 142 |
end |
| 143 | 143 |
end |
| 144 | ||
| 145 |
def test_sort_by_parent_id_asc_should_apply_asc_direction |
|
| 146 |
q = ProjectQuery.new |
|
| 147 |
q.sort_criteria = [['parent_id', 'asc']] |
|
| 148 |
sort_clause = q.sort_clause |
|
| 149 |
assert_not_nil sort_clause |
|
| 150 |
joined = sort_clause.map(&:to_s).join(' ')
|
|
| 151 |
# sort clause must use lft with ASC (user-chosen direction), not a hardcoded lft ASC |
|
| 152 |
assert_match(/lft ASC/i, joined) |
|
| 153 |
assert_no_match(/lft DESC/i, joined) |
|
| 154 |
end |
|
| 155 | ||
| 156 |
def test_sort_by_parent_id_desc_should_apply_desc_direction |
|
| 157 |
q = ProjectQuery.new |
|
| 158 |
q.sort_criteria = [['parent_id', 'desc']] |
|
| 159 |
sort_clause = q.sort_clause |
|
| 160 |
assert_not_nil sort_clause |
|
| 161 |
joined = sort_clause.map(&:to_s).join(' ')
|
|
| 162 |
# DESC direction must be applied (previously it was always fixed to ASC via lft ASC) |
|
| 163 |
assert_match(/lft DESC/i, joined) |
|
| 164 |
assert_no_match(/lft ASC/i, joined) |
|
| 165 |
end |
|
| 144 | 166 |
end |
- « Previous
- 1
- …
- 4
- 5
- 6
- Next »