Merge pull request #8064 from opf/fix/32296/also-sort-versions-by-name

[32296] Also ensure versions are sorted by name

[ci skip]
pull/8075/head
Oliver Günther 5 years ago committed by GitHub
commit b5f10922b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/queries/work_packages/columns/property_column.rb
  2. 3
      app/models/version.rb
  3. 3
      spec/models/query/sort_criteria_spec.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"

@ -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

@ -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

Loading…
Cancel
Save