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

Refactor ProjectSchemaRepresenter to use status_code/explanation columns

Aaron Contreras1c3c744378a9
diff --git a/lib/api/v3/projects/schemas/project_schema_representer.rb b/lib/api/v3/projects/schemas/project_schema_representer.rb
index 06311184b5d..3e2beacb85c 100644
--- a/lib/api/v3/projects/schemas/project_schema_representer.rb
+++ b/lib/api/v3/projects/schemas/project_schema_representer.rb
@@ -65,7 +65,7 @@ module API
type: 'ProjectStatus',
name_source: ->(*) { I18n.t('activerecord.attributes.projects/status.code') },
required: false,
- writable: ->(*) { represented.writable?(:status) },
+ writable: ->(*) { represented.writable?(:status_code) },
values_callback: ->(*) {
::Projects::Status.codes.keys
},
@@ -73,7 +73,7 @@ module API
link_factory: ->(value) {
{
href: api_v3_paths.project_status(value),
- title: I18n.t(:"activerecord.attributes.projects/status.codes.#{value}")
+ title: I18n.t(:"activerecord.attributes.project.status_codes.#{value}")
}
}
@@ -81,7 +81,7 @@ module API
type: 'Formattable',
name_source: ->(*) { I18n.t('activerecord.attributes.projects/status.explanation') },
required: false,
- writable: ->(*) { represented.writable?(:status) }
+ writable: ->(*) { represented.writable?(:status_explanation) }
schema_with_allowed_link :parent,
type: 'Project',
diff --git a/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb b/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb
index 908a9186715..a010d7c029c 100644
--- a/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb
+++ b/spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb
@@ -54,7 +54,8 @@ describe API::V3::Projects::Schemas::ProjectSchemaRepresenter do
allow(contract)
.to receive(:writable?) do |attribute|
- writable = %w(name identifier description public status parent active)
+ writable = %w(name identifier description public
+ status_code status_explanation parent active)
writable.include?(attribute.to_s)
end
@@ -65,7 +66,7 @@ describe API::V3::Projects::Schemas::ProjectSchemaRepresenter do
allow(contract)
.to receive(:assignable_values)
- .with(:status, current_user)
+ .with(:status_code, current_user)
.and_return(allowed_status)
allow(contract)