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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
case insensitive order for projects
ulfertsea65cf10b2ab
diff --git a/app/models/queries/projects.rb b/app/models/queries/projects.rbindex 5c6ff277bf5..643725cdc4f 100644--- a/app/models/queries/projects.rb+++ b/app/models/queries/projects.rb@@ -51,4 +51,5 @@ module Queries::Projectsregister.order query, orders::RequiredDiskSpaceOrderregister.order query, orders::CustomFieldOrderregister.order query, orders::ProjectStatusOrder+ register.order query, orders::NameOrderenddiff --git a/app/models/queries/projects/orders/default_order.rb b/app/models/queries/projects/orders/default_order.rbindex cb16eb6e38b..10405f4a1c5 100644--- a/app/models/queries/projects/orders/default_order.rb+++ b/app/models/queries/projects/orders/default_order.rb@@ -32,6 +32,6 @@ class Queries::Projects::Orders::DefaultOrder < Queries::BaseOrderself.model = Projectdef self.key- /\A(id|name|created_at|public|lft)\z/+ /\A(id|created_at|public|lft)\z/endenddiff --git a/app/models/queries/projects/orders/name_order.rb b/app/models/queries/projects/orders/name_order.rbnew file mode 100644index 00000000000..0a5a2932753--- /dev/null+++ b/app/models/queries/projects/orders/name_order.rb@@ -0,0 +1,43 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2020 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2017 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See docs/COPYRIGHT.rdoc for more details.+#++++class Queries::Projects::Orders::NameOrder < Queries::BaseOrder+ self.model = Project++ def self.key+ :name+ end++ def order+ with_raise_on_invalid do+ model.order(Arel.sql("lower(projects.name)").send(direction))+ end+ end+enddiff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rbindex 03451d5d466..bcef064eb08 100644--- a/spec/features/projects/projects_index_spec.rb+++ b/spec/features/projects/projects_index_spec.rb@@ -816,6 +816,11 @@ describe 'Projects index page',parent: project,name: "Z Child")end+ let!(:child_project_m) do+ FactoryBot.create(:project,+ parent: project,+ name: "m Child") # intentionally written lowercase to test for case insensitive sorting+ endlet!(:child_project_a) doFactoryBot.create(:project,parent: project,@@ -835,6 +840,8 @@ describe 'Projects index page',public_project.save!child_project_z.custom_field_values = { integer_custom_field.id => 4 }child_project_z.save!+ child_project_m.custom_field_values = { integer_custom_field.id => 4 }+ child_project_m.save!child_project_a.custom_field_values = { integer_custom_field.id => 4 }child_project_a.save!end@@ -844,6 +851,7 @@ describe 'Projects index page',expect_projects_in_order(development_project,project,child_project_a,+ child_project_m,child_project_z,public_project)@@ -852,6 +860,7 @@ describe 'Projects index page',# Projects ordered by name ascexpect_projects_in_order(child_project_a,development_project,+ child_project_m,project,public_project,child_project_z)@@ -862,6 +871,7 @@ describe 'Projects index page',expect_projects_in_order(child_project_z,public_project,project,+ child_project_m,development_project,child_project_a)@@ -872,6 +882,7 @@ describe 'Projects index page',development_project,public_project,child_project_z,+ child_project_m,child_project_a)click_link('Sort by "Project hierarchy"')@@ -880,18 +891,19 @@ describe 'Projects index page',expect_projects_in_order(development_project,project,child_project_a,+ child_project_m,child_project_z,public_project)end+ end- feature 'blacklisted filters' do- scenario 'are not visible' do- load_and_open_filters admin+ feature 'blacklisted filters' do+ scenario 'are not visible' do+ load_and_open_filters admin- expect(page).to_not have_select('add_filter_select', with_options: ["Principal"])- expect(page).to_not have_select('add_filter_select', with_options: ["ID"])- expect(page).to_not have_select('add_filter_select', with_options: ["Subproject of"])- end+ expect(page).to_not have_select('add_filter_select', with_options: ["Principal"])+ expect(page).to_not have_select('add_filter_select', with_options: ["ID"])+ expect(page).to_not have_select('add_filter_select', with_options: ["Subproject of"])endendend