Skip to content

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

Update schema representer specs to mark % complete as read-only

Aaron Contreras80b10315d068
diff --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.rb
index e6d24160d44..a1d9745370c 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
@@ -169,25 +169,9 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
describe '#writable?' do
describe '% Complete' do
- it 'is not writable when inferred by status' do
- allow(Setting).to receive(:work_package_done_ratio).and_return('status')
+ it 'is not writable' do
expect(subject).not_to be_writable(:done_ratio)
end
-
- it 'is not writable when disabled' do
- allow(Setting).to receive(:work_package_done_ratio).and_return('disabled')
- expect(subject).not_to be_writable(:done_ratio)
- end
-
- it 'is writable when the work package is a parent' do
- allow(work_package).to receive(:leaf?).and_return(false)
- expect(subject).to be_writable(:done_ratio)
- end
-
- it 'is writable when the work package is a leaf' do
- allow(work_package).to receive(:leaf?).and_return(true)
- expect(subject).to be_writable('done_ratio')
- end
end
describe 'work' do
diff --git a/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb b/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb
index cf8c110fb37..e7bcac679f8 100644
--- a/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb
@@ -58,8 +58,8 @@ RSpec.describe API::V3::WorkPackages::Schema::TypedWorkPackageSchema do
end
describe '#writable?' do
- it 'percentage done is writable' do
- expect(subject).to be_writable(:done_ratio)
+ it 'percentage done is not writable' do
+ expect(subject).not_to be_writable(:done_ratio)
end
it 'work is writable' do
diff --git a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
index 8b6eae5256c..cc573c5e4cd 100644
--- a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
@@ -656,30 +656,12 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
describe 'percentageDone' do
- before do
- allow(schema).to receive(:writable?).with('done_ratio').and_return true
- end
-
it_behaves_like 'has basic schema properties' do
let(:path) { 'percentageDone' }
let(:type) { 'Integer' }
let(:name) { I18n.t('activerecord.attributes.work_package.done_ratio') }
let(:required) { false }
- let(:writable) { true }
- end
-
- context 'when not writable' do
- before do
- allow(schema).to receive(:writable?).with('done_ratio').and_return false
- end
-
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'percentageDone' }
- let(:type) { 'Integer' }
- let(:name) { I18n.t('activerecord.attributes.work_package.done_ratio') }
- let(:required) { false }
- let(:writable) { false }
- end
+ let(:writable) { false }
end
context 'as disabled' do