diff --git a/modules/backlogs/lib/open_project/backlogs/engine.rb b/modules/backlogs/lib/open_project/backlogs/engine.rb index 442274a2339..db276976a9f 100644 --- a/modules/backlogs/lib/open_project/backlogs/engine.rb +++ b/modules/backlogs/lib/open_project/backlogs/engine.rb @@ -234,16 +234,10 @@ module OpenProject::Backlogs end config.to_prepare do - %i[position story_points sprint].each do |attribute| + %i[position story_points sprint backlog_bucket].each do |attribute| ::Type.add_constraint attribute, ->(_type, project: nil) { project.nil? || project.backlogs_enabled? } end - story_and_sprint_permission = ->(_type, project: nil) do - project.nil? || User.current.allowed_in_project?(:view_sprints, project) - end - - ::Type.add_constraint :backlog_bucket, story_and_sprint_permission - ::Type.add_default_mapping(:estimates_and_progress, :story_points) ::Type.add_default_mapping(:other, :position) ::Type.add_default_mapping(:details, :sprint) diff --git a/modules/backlogs/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/modules/backlogs/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb index ca81938fddf..b4c0a169b38 100644 --- a/modules/backlogs/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb +++ b/modules/backlogs/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb @@ -44,7 +44,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do allow(p).to receive(:backlogs_enabled?).and_return(backlogs_enabled) end end - let(:work_package_type) { build_stubbed(:type, attribute_groups: [["Agile", %w[position sprint story_points]]]) } + let(:work_package_type) { build_stubbed(:type, attribute_groups: [["Agile", %w[position sprint story_points backlog_bucket]]]) } let(:work_package) { build_stubbed(:work_package, type: work_package_type) } let(:current_user) { build_stubbed(:user) } @@ -138,7 +138,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do describe "attribute_groups" do context "with backlogs enabled" do it "has backlogs properties listed in the right group" do - expect(subject).to be_json_eql(%w[position sprint storyPoints]) + expect(subject).to be_json_eql(%w[position sprint storyPoints backlogBucket]) .at_path("_attributeGroups/0/attributes") end end @@ -147,7 +147,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do let(:permissions) { %i(view_work_packages edit_work_packages) } it "has backlogs properties listed in the right group" do - expect(subject).to be_json_eql(%w[position sprint storyPoints]) + expect(subject).to be_json_eql(%w[position sprint storyPoints backlogBucket]) .at_path("_attributeGroups/0/attributes") end end