Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[32296] Also ensure versions are sorted by name

Oliver Güntherfa33b8c2966b
diff --git a/app/models/queries/work_packages/columns/property_column.rb b/app/models/queries/work_packages/columns/property_column.rb
index f510b2995e5..6c57a16b4c8 100644
--- a/app/models/queries/work_packages/columns/property_column.rb
+++ b/app/models/queries/work_packages/columns/property_column.rb
@@ -97,7 +97,7 @@ class Queries::WorkPackages::Columns::PropertyColumn < Queries::WorkPackages::Co
},
fixed_version: {
association: 'fixed_version',
- sortable: %w(start_date effective_date),
+ sortable: %w(start_date effective_date name),
default_order: 'DESC',
null_handling: 'NULLS LAST',
groupable: "#{WorkPackage.table_name}.fixed_version_id"
diff --git a/app/models/version.rb b/app/models/version.rb
index 98207a66f05..2b673d96ab8 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -60,7 +60,8 @@ class Version < ActiveRecord::Base
scope :order_by_newest_date, -> {
reorder Arel.sql("#{Version.table_name}.start_date DESC NULLS LAST,
- #{Version.table_name}.effective_date DESC NULLS LAST")
+ #{Version.table_name}.effective_date DESC NULLS LAST,
+ #{Version.table_name}.name ASC")
}
def self.with_status_open
diff --git a/spec/models/query/sort_criteria_spec.rb b/spec/models/query/sort_criteria_spec.rb
index d0d349aaa1d..594c8486b01 100644
--- a/spec/models/query/sort_criteria_spec.rb
+++ b/spec/models/query/sort_criteria_spec.rb
@@ -77,7 +77,8 @@ describe ::Query::SortCriteria, type: :model, with_mail: false do
it 'adds the order handling' do
expect(subject.length).to eq 2
- expect(subject.first).to eq ['start_date DESC NULLS LAST', 'effective_date DESC NULLS LAST']
+ expect(subject.first)
+ .to eq ['start_date DESC NULLS LAST', 'effective_date DESC NULLS LAST', 'name DESC NULLS LAST']
expect(subject.last).to eq ['work_packages.start_date NULLS LAST']
end
end