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
Allow users to edit project queries who have the edit permissions
Aaron Contreras8b4d9b00ac05
diff --git a/app/contracts/queries/projects/project_queries/base_contract.rb b/app/contracts/queries/projects/project_queries/base_contract.rbindex a98d9fa807c..446f0b23316 100644--- a/app/contracts/queries/projects/project_queries/base_contract.rb+++ b/app/contracts/queries/projects/project_queries/base_contract.rb@@ -57,10 +57,10 @@ module Queries::Projects::ProjectQueriesdef allowed_to_modify_private_queryreturn if model.public?+ return if model.user == user+ return if user.allowed_in_project_query?(:edit_project_query, model)- if model.user != user- errors.add :base, :can_only_be_modified_by_owner- end+ errors.add :base, :can_only_be_modified_by_ownerenddef allowed_to_modify_public_querydiff --git a/spec/contracts/queries/projects/project_queries/shared_contract_examples.rb b/spec/contracts/queries/projects/project_queries/shared_contract_examples.rbindex a553cbdb549..6cff8337a1a 100644--- a/spec/contracts/queries/projects/project_queries/shared_contract_examples.rb+++ b/spec/contracts/queries/projects/project_queries/shared_contract_examples.rb@@ -52,12 +52,24 @@ RSpec.shared_examples_for "project queries contract" doit_behaves_like "contract is invalid", name: :too_longend- context "if the user is not the current user" do+ context "if the user is not the current user and does not have the permission" dolet(:query_user) { build_stubbed(:user) }it_behaves_like "contract is invalid", base: :can_only_be_modified_by_ownerend+ context "if the user is not the current user but has the permission" do+ let(:query_user) { build_stubbed(:user) }++ before do+ mock_permissions_for(current_user) do |mock|+ mock.allow_in_project_query :edit_project_query, project_query: query+ end+ end++ it_behaves_like "contract is valid"+ end+context "if the list is public and the editing user has the permission" dolet(:query_user) { build_stubbed(:user) }