From 38cc9ff7166e884fbe269b2d7f296f76b33dc1f1 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Wed, 23 Sep 2015 09:50:14 +0200 Subject: [PATCH 1/2] remove outdated comment --- frontend/app/services/version-service.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/app/services/version-service.js b/frontend/app/services/version-service.js index 592844b4c2..e459529959 100644 --- a/frontend/app/services/version-service.js +++ b/frontend/app/services/version-service.js @@ -30,7 +30,6 @@ module.exports = function($http, PathHelper) { var VersionService = { - // TODO: check if code invoked anywere getVersions: function(projectIdentifier) { var url; From 4bfc4cc8b2643df67b985940f52e334f6f9c1f84 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Wed, 23 Sep 2015 09:50:49 +0200 Subject: [PATCH 2/2] sort versions case insensitive --- app/models/version.rb | 2 +- frontend/app/services/version-service.js | 4 +- ...ork-package-field-configuration-service.js | 4 +- spec/models/version_spec.rb | 43 +++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/app/models/version.rb b/app/models/version.rb index 832e0a040a..9ed5febebc 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -205,7 +205,7 @@ class Version < ActiveRecord::Base # tie the comparison to the presentation as sorting is mostly # used within sorted tables. # Thus, when the representation changes, the sorting will change as well. - to_s_with_project <=> version.to_s_with_project + to_s_with_project.downcase <=> version.to_s_with_project.downcase end # Returns the sharings that +user+ can set the version to diff --git a/frontend/app/services/version-service.js b/frontend/app/services/version-service.js index e459529959..45685cd007 100644 --- a/frontend/app/services/version-service.js +++ b/frontend/app/services/version-service.js @@ -45,7 +45,9 @@ module.exports = function($http, PathHelper) { doQuery: function(url, params) { return $http.get(url, { params: params }) .then(function(response){ - return _.sortBy(response.data.versions, 'name'); + return _.sortBy(response.data.versions, function(version) { + return version.name.toLowerCase(); + }); }); } }; diff --git a/frontend/app/work_packages/services/work-package-field-configuration-service.js b/frontend/app/work_packages/services/work-package-field-configuration-service.js index 271fbe528f..2b9bda5a96 100644 --- a/frontend/app/work_packages/services/work-package-field-configuration-service.js +++ b/frontend/app/work_packages/services/work-package-field-configuration-service.js @@ -32,7 +32,9 @@ module.exports = function() { switch(field) { case 'version': - sorting = 'title'; + sorting = function(field) { + return field.title.toLowerCase(); + }; break; default: sorting = null; diff --git a/spec/models/version_spec.rb b/spec/models/version_spec.rb index 887c7ac558..988e859585 100644 --- a/spec/models/version_spec.rb +++ b/spec/models/version_spec.rb @@ -127,6 +127,49 @@ describe Version, type: :model do expect(version1 <=> version2).to eql 1 end + + it 'is 0 if name and project are equal except for case' do + version1.project.name = version2.project.name.upcase + version1.name = version2.name.upcase + + expect(version1 <=> version2).to be 0 + end + + it "is -1 if the project name is alphabetically before the other's project name ignoring case" do + version1.name = 'BBBB' + version1.project.name = 'aaaa' + version2.name = 'AAAA' + version2.project.name = 'BBBB' + + expect(version1 <=> version2).to eql -1 + end + + it "is 1 if the project name is alphabetically after the other's project name ignoring case" do + version1.name = 'AAAA' + version1.project.name = 'BBBB' + version2.name = 'BBBB' + version2.project.name = 'aaaa' + + expect(version1 <=> version2).to eql 1 + end + + it "is -1 if the project name is equal + and the version's name is alphabetically before the other's name ignoring case" do + version1.project.name = version2.project.name + version1.name = 'aaaa' + version2.name = 'BBBB' + + expect(version1 <=> version2).to eql -1 + end + + it "is 1 if the project name is equal + and the version's name is alphabetically after the other's name ignoring case" do + version1.project.name = version2.project.name + version1.name = 'BBBB' + version2.name = 'aaaa' + + expect(version1 <=> version2).to eql 1 + end end context '#projects' do