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
Correctly wrap one error in invalid query, using create_if_many
Oliver Günther60c32f1982be
diff --git a/lib/api/v3/notifications/notifications_api.rb b/lib/api/v3/notifications/notifications_api.rbindex cdf86481c8c..937b6dfffb1 100644--- a/lib/api/v3/notifications/notifications_api.rb+++ b/lib/api/v3/notifications/notifications_api.rb@@ -55,7 +55,11 @@ module APInotification_query.results.update_all({ updated_at: Time.zone.now }.merge(attributes))status 204else- raise ::API::Errors::InvalidQuery.new(notification_query.errors.full_messages)+ api_errors = notification_query.errors.full_messages.map do |message|+ ::API::Errors::InvalidQuery.new(message)+ end++ raise ::API::Errors::MultipleErrors.create_if_many api_errorsendendenddiff --git a/lib/api/v3/queries/helpers/query_representer_response.rb b/lib/api/v3/queries/helpers/query_representer_response.rbindex 8bb5c9339d7..cab6a04c159 100644--- a/lib/api/v3/queries/helpers/query_representer_response.rb+++ b/lib/api/v3/queries/helpers/query_representer_response.rb@@ -43,7 +43,11 @@ module APIembed_links: true,params:)else- raise ::API::Errors::InvalidQuery.new(representer.errors.full_messages)+ api_errors = query.errors.full_messages.map do |message|+ ::API::Errors::InvalidQuery.new(message)+ end++ raise ::API::Errors::MultipleErrors.create_if_many api_errorsendendenddiff --git a/lib/api/v3/utilities/endpoints/index.rb b/lib/api/v3/utilities/endpoints/index.rbindex 6bfb7a4a82e..0ff37ba185c 100644--- a/lib/api/v3/utilities/endpoints/index.rb+++ b/lib/api/v3/utilities/endpoints/index.rb@@ -135,7 +135,11 @@ module APIenddef render_error(query)- raise ::API::Errors::InvalidQuery.new(query.errors.full_messages)+ api_errors = query.errors.full_messages.map do |message|+ ::API::Errors::InvalidQuery.new(message)+ end++ raise ::API::Errors::MultipleErrors.create_if_many api_errorsenddef calculated_self_path(request)diff --git a/lib/api/v3/utilities/params_to_query.rb b/lib/api/v3/utilities/params_to_query.rbindex 6b67a4bbc30..caa1c3b1c89 100644--- a/lib/api/v3/utilities/params_to_query.rb+++ b/lib/api/v3/utilities/params_to_query.rb@@ -46,7 +46,11 @@ module APIrepresenter,self_link)else- raise ::API::Errors::InvalidQuery.new(query.errors.full_messages)+ api_errors = query.errors.full_messages.map do |message|+ ::API::Errors::InvalidQuery.new(message)+ end++ raise ::API::Errors::MultipleErrors.create_if_many api_errorsendenddiff --git a/modules/documents/lib/api/v3/documents/documents_api.rb b/modules/documents/lib/api/v3/documents/documents_api.rbindex 23e0de795c2..ac724272205 100644--- a/modules/documents/lib/api/v3/documents/documents_api.rb+++ b/modules/documents/lib/api/v3/documents/documents_api.rb@@ -45,7 +45,11 @@ module APIper_page: resolve_page_size(params[:pageSize]),current_user:)else- raise ::API::Errors::InvalidQuery.new(query.errors.full_messages)+ api_errors = query.errors.full_messages.map do |message|+ ::API::Errors::InvalidQuery.new(message)+ end++ raise ::API::Errors::MultipleErrors.create_if_many api_errorsendenddiff --git a/modules/grids/app/controllers/api/v3/grids/grids_api.rb b/modules/grids/app/controllers/api/v3/grids/grids_api.rbindex f0508a67d38..a0bb01d2e45 100644--- a/modules/grids/app/controllers/api/v3/grids/grids_api.rb+++ b/modules/grids/app/controllers/api/v3/grids/grids_api.rb@@ -48,7 +48,11 @@ module APIper_page: resolve_page_size(params[:pageSize]),current_user:)else- raise ::API::Errors::InvalidQuery.new(query.errors.full_messages)+ api_errors = query.errors.full_messages.map do |message|+ ::API::Errors::InvalidQuery.new(message)+ end++ raise ::API::Errors::MultipleErrors.create_if_many api_errorsendenddiff --git a/spec/requests/api/v3/capability_resource_spec.rb b/spec/requests/api/v3/capability_resource_spec.rbindex 1fb9c1b1f64..c74494807cf 100644--- a/spec/requests/api/v3/capability_resource_spec.rb+++ b/spec/requests/api/v3/capability_resource_spec.rb@@ -259,9 +259,9 @@ describe 'API v3 capabilities resource', type: :request, content_type: :json do} }]end- it 'returns 400' do+ it 'returns 422' doexpect(subject.status)- .to be 400+ .to be 422endit 'communicates the error message' do@@ -270,7 +270,7 @@ describe 'API v3 capabilities resource', type: :request, content_type: :json do.at_path('_type')expect(subject.body)- .to be_json_eql('urn:openproject-org:api:v3:errors:InvalidQuery'.to_json)+ .to be_json_eql('urn:openproject-org:api:v3:errors:MultipleErrors'.to_json).at_path('errorIdentifier')endend