|
|
|
@ -85,8 +85,8 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do |
|
|
|
|
.and_return(true) |
|
|
|
|
|
|
|
|
|
expect(subject).to be_readonly |
|
|
|
|
expect(subject.writable?(:status)).to be_truthy |
|
|
|
|
expect(subject.writable?(:subject)).to be_falsey |
|
|
|
|
expect(subject).to be_writable('status') |
|
|
|
|
expect(subject).not_to be_writable('subject') |
|
|
|
|
|
|
|
|
|
allow(work_package) |
|
|
|
|
.to receive(:readonly_status?) |
|
|
|
@ -95,8 +95,8 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do |
|
|
|
|
# As the writability is memoized we need to have a new schema |
|
|
|
|
new_schema = described_class.new(work_package:) |
|
|
|
|
expect(new_schema).not_to be_readonly |
|
|
|
|
expect(new_schema.writable?(:status)).to be_truthy |
|
|
|
|
expect(new_schema.writable?(:subject)).to be_truthy |
|
|
|
|
expect(new_schema).to be_writable('status') |
|
|
|
|
expect(new_schema).to be_writable('subject') |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -176,46 +176,46 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do |
|
|
|
|
context 'percentage done' do |
|
|
|
|
it 'is not writable when inferred by status' do |
|
|
|
|
allow(Setting).to receive(:work_package_done_ratio).and_return('status') |
|
|
|
|
expect(subject.writable?(:percentage_done)).to be false |
|
|
|
|
expect(subject.writable?('done_ratio')).to be false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'is not writable when disabled' do |
|
|
|
|
allow(Setting).to receive(:work_package_done_ratio).and_return('disabled') |
|
|
|
|
expect(subject.writable?(:percentage_done)).to be false |
|
|
|
|
expect(subject.writable?('done_ratio')).to be false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'is not writable when the work package is a parent' do |
|
|
|
|
allow(work_package).to receive(:leaf?).and_return(false) |
|
|
|
|
expect(subject.writable?(:percentage_done)).to be false |
|
|
|
|
expect(subject.writable?('done_ratio')).to be false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'is writable when the work package is a leaf' do |
|
|
|
|
allow(work_package).to receive(:leaf?).and_return(true) |
|
|
|
|
expect(subject.writable?(:percentage_done)).to be true |
|
|
|
|
expect(subject.writable?('done_ratio')).to be true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'estimated time' do |
|
|
|
|
it 'is writable when the work package is a parent' do |
|
|
|
|
allow(work_package).to receive(:leaf?).and_return(false) |
|
|
|
|
expect(subject.writable?(:estimated_time)).to be true |
|
|
|
|
expect(subject.writable?('estimated_hours')).to be true |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'is writable when the work package is a leaf' do |
|
|
|
|
allow(work_package).to receive(:leaf?).and_return(true) |
|
|
|
|
expect(subject.writable?(:estimated_time)).to be true |
|
|
|
|
expect(subject.writable?('estimated_hours')).to be true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'derived estimated time' 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?(:derived_estimated_time)).to be false |
|
|
|
|
expect(subject.writable?('derived_estimated_time')).to be false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'is not writable when the work package is a leaf' do |
|
|
|
|
allow(work_package).to receive(:leaf?).and_return(true) |
|
|
|
|
expect(subject.writable?(:derived_estimated_time)).to be false |
|
|
|
|
expect(subject.writable?('derived_estimated_time')).to be false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -229,7 +229,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do |
|
|
|
|
|
|
|
|
|
context 'scheduled automatically' do |
|
|
|
|
it 'is not writable' do |
|
|
|
|
expect(subject.writable?(:start_date)).to be false |
|
|
|
|
expect(subject.writable?('start_date')).to be false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -239,7 +239,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'is writable' do |
|
|
|
|
expect(subject.writable?(:start_date)).to be true |
|
|
|
|
expect(subject.writable?('start_date')).to be true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -247,7 +247,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do |
|
|
|
|
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 |
|
|
|
|
expect(subject.writable?('start_date')).to be true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -262,7 +262,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do |
|
|
|
|
|
|
|
|
|
context 'scheduled automatically' do |
|
|
|
|
it 'is not writable' do |
|
|
|
|
expect(subject.writable?(:due_date)).to be false |
|
|
|
|
expect(subject.writable?('due_date')).to be false |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -272,7 +272,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'is writable' do |
|
|
|
|
expect(subject.writable?(:due_date)).to be true |
|
|
|
|
expect(subject.writable?('due_date')).to be true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -280,7 +280,7 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do |
|
|
|
|
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 |
|
|
|
|
expect(subject.writable?('due_date')).to be true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -294,24 +294,24 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema 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?(:date)).to be false |
|
|
|
|
expect(subject.writable?('date')).to be false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'is writable when the work package is a leaf' do |
|
|
|
|
allow(work_package).to receive(:leaf?).and_return(true) |
|
|
|
|
expect(subject.writable?(:date)).to be true |
|
|
|
|
expect(subject.writable?('date')).to be true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'priority' do |
|
|
|
|
it 'is writable when the work package is a parent' do |
|
|
|
|
allow(work_package).to receive(:leaf?).and_return(false) |
|
|
|
|
expect(subject.writable?(:priority)).to be true |
|
|
|
|
expect(subject.writable?('priority')).to be true |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it 'is writable when the work package is a leaf' do |
|
|
|
|
allow(work_package).to receive(:leaf?).and_return(true) |
|
|
|
|
expect(subject.writable?(:priority)).to be true |
|
|
|
|
expect(subject.writable?('priority')).to be true |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|