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

[#50910] replaced operator * with &= for user action 'all'

Eric Schubert259f3e7bb203
diff --git a/app/models/queries/filters/strategies/list_all.rb b/app/models/queries/filters/strategies/list_all.rb
index 743a7efc47a..5b8a7bfd5d6 100644
--- a/app/models/queries/filters/strategies/list_all.rb
+++ b/app/models/queries/filters/strategies/list_all.rb
@@ -28,6 +28,13 @@
module Queries::Filters::Strategies
class ListAll < List
- self.supported_operators = ['=', '!', '*']
+ self.supported_operators = %w[= ! &=]
+
+ def operator_map
+ super_value = super.dup
+ super_value['&='] = ::Queries::Operators::EqualsAll
+
+ super_value
+ end
end
end
diff --git a/app/models/queries/operators/equals_all.rb b/app/models/queries/operators/equals_all.rb
new file mode 100644
index 00000000000..45aa9cdcb33
--- /dev/null
+++ b/app/models/queries/operators/equals_all.rb
@@ -0,0 +1,34 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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-2013 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 COPYRIGHT and LICENSE files for more details.
+#++
+
+module Queries::Operators
+ class EqualsAll < Base
+ label 'equals_all'
+ set_symbol '&='
+ end
+end
diff --git a/app/models/queries/projects/filters/user_action_filter.rb b/app/models/queries/projects/filters/user_action_filter.rb
index ebd0d7ef8f9..e03021e8959 100644
--- a/app/models/queries/projects/filters/user_action_filter.rb
+++ b/app/models/queries/projects/filters/user_action_filter.rb
@@ -39,7 +39,7 @@ module Queries
end
def where
- operator = if operator_class <= ::Queries::Operators::Equals || operator_class <= ::Queries::Operators::All
+ operator = if operator_class <= ::Queries::Operators::Equals || operator_class <= ::Queries::Operators::EqualsAll
'IN'
elsif operator_class <= ::Queries::Operators::NotEquals
'NOT IN'
@@ -55,7 +55,7 @@ module Queries
private
def capability_select_queries
- if operator_class <= ::Queries::Operators::All
+ if operator_class <= ::Queries::Operators::EqualsAll
values.map do |val|
Capability
.where(action: val)
diff --git a/spec/requests/api/v3/projects/index_resource_spec.rb b/spec/requests/api/v3/projects/index_resource_spec.rb
index b2ecd3cfdae..77415201fcf 100644
--- a/spec/requests/api/v3/projects/index_resource_spec.rb
+++ b/spec/requests/api/v3/projects/index_resource_spec.rb
@@ -129,7 +129,7 @@ RSpec.describe 'API v3 Project resource index', content_type: :json do
end
context 'if using the all operator' do
- let(:operator) { '*' }
+ let(:operator) { '&=' }
it_behaves_like 'API V3 collection response', 1, 1, 'Project'