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
adjust contract to allow setting dates on manually scheduled parent wps
ulfertsc5ead62e0a9d
diff --git a/app/contracts/work_packages/base_contract.rb b/app/contracts/work_packages/base_contract.rbindex 786d2c28d46..f4aced3b8c0 100644--- a/app/contracts/work_packages/base_contract.rb+++ b/app/contracts/work_packages/base_contract.rb@@ -84,7 +84,7 @@ module WorkPackagesattribute :start_date,writeable: ->(*) {- model.leaf?+ model.leaf? || model.schedule_manually?} doif start_before_soonest_start?message = I18n.t('activerecord.errors.models.work_package.attributes.start_date.violates_relationships',@@ -96,7 +96,7 @@ module WorkPackagesattribute :due_date,writeable: ->(*) {- model.leaf?+ model.leaf? || model.schedule_manually?}validates :due_date,diff --git a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb b/spec/features/work_packages/scheduling/scheduling_mode_spec.rbindex ba76246d9a8..27a491f1a38 100644--- a/spec/features/work_packages/scheduling/scheduling_mode_spec.rb+++ b/spec/features/work_packages/scheduling/scheduling_mode_spec.rb@@ -84,7 +84,7 @@ describe 'scheduling mode',let(:user) { FactoryBot.create :admin }let(:work_packages_page) { Pages::SplitWorkPackage.new(wp, project) }- let(:start_date) { work_packages_page.edit_field(:startDate) }+ let(:combined_field) { work_packages_page.edit_field(:combinedDate) }before dologin_as(user)@@ -95,14 +95,14 @@ describe 'scheduling mode',it 'can toggle the scheduling mode through the date modal' doexpect(wp.schedule_manually).to eq false- start_date.activate!- start_date.expect_active!+ combined_field.activate!+ combined_field.expect_active!- start_date.expect_scheduling_mode manually: false- start_date.toggle_scheduling_mode- start_date.expect_scheduling_mode manually: true+ combined_field.expect_scheduling_mode manually: false+ combined_field.toggle_scheduling_mode+ combined_field.expect_scheduling_mode manually: true- start_date.save!+ combined_field.save!work_packages_page.expect_and_dismiss_notification message: 'Successful update.'work_package.reloaddiff --git a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rbindex e46f60a8c12..9163f8f1684 100644--- a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb+++ b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb@@ -208,30 +208,74 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema doendcontext 'start date' do- it 'is not writable when the work package is a parent' do- allow(work_package).to receive(:leaf?).and_return(false)- expect(subject.writable?(:start_date)).to be false+ context 'work package is parent' do+ before do+ allow(work_package)+ .to receive(:leaf?)+ .and_return(false)+ end++ context 'scheduled automatically' do+ it 'is not writable' do+ expect(subject.writable?(:start_date)).to be false+ end+ end++ context 'scheduled manually' do+ before do+ work_package.schedule_manually = true+ end++ it 'is writable' do+ expect(subject.writable?(:start_date)).to be true+ end+ endend- it 'is writable when the work package is a leaf' do- allow(work_package).to receive(:leaf?).and_return(true)- expect(subject.writable?(:start_date)).to be true+ context 'work package is a leaf' do+ it 'is writable' do+ allow(work_package).to receive(:leaf?).and_return(true)+ expect(subject.writable?(:start_date)).to be true+ endendend- context 'finish date' do- it 'is not writable when the work package is a parent' do- allow(work_package).to receive(:leaf?).and_return(false)- expect(subject.writable?(:due_date)).to be false+ context 'due date' do+ context 'work package is parent' do+ before do+ allow(work_package)+ .to receive(:leaf?)+ .and_return(false)+ end++ context 'scheduled automatically' do+ it 'is not writable' do+ expect(subject.writable?(:due_date)).to be false+ end+ end++ context 'scheduled manually' do+ before do+ work_package.schedule_manually = true+ end++ it 'is writable' do+ expect(subject.writable?(:due_date)).to be true+ end+ endend- it 'is writable when the work package is a leaf' do- allow(work_package).to receive(:leaf?).and_return(true)- expect(subject.writable?(:due_date)).to be true+ context 'work package is a leaf' do+ it 'is writable' do+ allow(work_package).to receive(:leaf?).and_return(true)+ expect(subject.writable?(:due_date)).to be true+ endendendcontext 'date' do+ # As a date only exists on milestones, which can have no children+ # we do not need to check for differences caused by scheduling modes.before doallow(work_package.type).to receive(:is_milestone?).and_return(true)end