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
Fix tests after status / explanation breakup
Oliver Günthere1e9edd66817
diff --git a/frontend/src/app/modules/grids/widgets/project-status/project-status.component.html b/frontend/src/app/modules/grids/widgets/project-status/project-status.component.htmlindex e339d32ef3e..e52fd24706d 100644--- a/frontend/src/app/modules/grids/widgets/project-status/project-status.component.html+++ b/frontend/src/app/modules/grids/widgets/project-status/project-status.component.html@@ -11,7 +11,7 @@<div class="grid--widget-content"><edit-form *ngIf="(project$ | async) as project" [resource]="project"><editable-attribute-field [resource]="project"- fieldName="statusCode">+ fieldName="status"></editable-attribute-field><editable-attribute-field [resource]="project"fieldName="statusExplanation">diff --git a/lib/api/v3/projects/project_representer.rb b/lib/api/v3/projects/project_representer.rbindex 6c59442d138..2e91d888559 100644--- a/lib/api/v3/projects/project_representer.rb+++ b/lib/api/v3/projects/project_representer.rb@@ -162,32 +162,33 @@ module APIdate_time_property :updated_at- formattable_property :status_explanation,- getter: ->(*) {- status = represented.status || Project::Status.new- ::API::Decorators::Formattable.new(status.explanation,- object: represented,- plain: false)- },- setter: ->(fragment:, **) {- represented.status ||= {}- represented.status[:explanation] = fragment["raw"]- }-- property :status_code,+ property :status_explanation,+ getter: ->(*) {+ status_obj = status || Project::Status.new+ ::API::Decorators::Formattable.new(status_obj.explanation,+ object: self,+ plain: false)+ },+ setter: ->(fragment:, **) {+ self.status ||= {}+ status[:explanation] = fragment["raw"]+ }++ property :status,render_nil: true,- getter: ->(represented:, **) {- next unless represented.status&.code+ getter: ->(*) {+ next unless status&.code- represented.status.code.to_s.tr('_', ' ')+ status.code.to_s.tr('_', ' ')},- setter: ->(fragment:,represented:, **) {- represented.status ||= {}- represented.status[:code] = if fragment.nil?- nil- else- fragment.strip.tr(' ', '_').underscore.to_sym- end+ setter: ->(fragment:, **) {+ self.status ||= {}+ status[:code] =+ if fragment.nil?+ nil+ else+ fragment.strip.tr(' ', '_').underscore.to_sym+ end}def _typediff --git a/lib/api/v3/projects/schemas/project_schema_representer.rb b/lib/api/v3/projects/schemas/project_schema_representer.rbindex d90cdbafa2b..8ecde8b072a 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 APItype: 'Boolean',visibility: false- schema :status_code,+ schema :status,type: 'ProjectStatus',name_source: ->(*) { I18n.t('activerecord.attributes.project/status.code') },visibility: false,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.rbindex 71d927698b0..12928d33bbf 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@@ -183,14 +183,14 @@ describe ::API::V3::Projects::Schemas::ProjectSchemaRepresenter dolet(:path) { 'statusExplanation' }it_behaves_like 'has basic schema properties' do- let(:type) { 'Formattible' }+ let(:type) { 'Formattable' }let(:name) { I18n.t('activerecord.attributes.project/status.explanation') }let(:required) { false }let(:writable) { true }endend- describe 'statusCode' do+ describe 'status' dolet(:path) { 'status' }it_behaves_like 'has basic schema properties' dodiff --git a/spec/requests/api/v3/project_resource_spec.rb b/spec/requests/api/v3/project_resource_spec.rbindex c1daf9fc741..2ed09096a2f 100644--- a/spec/requests/api/v3/project_resource_spec.rb+++ b/spec/requests/api/v3/project_resource_spec.rb@@ -111,7 +111,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json doexpect(subject.body).to be_json_eql(project_status.code.tr('_', ' ').to_json)- .at_path("statusCode")+ .at_path("status")endcontext 'requesting nonexistent project' do@@ -299,7 +299,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json do{identifier: 'new_project_identifier',name: 'Project name',- statusCode: 'off track',+ status: 'off track',statusExplanation: { raw: "Some explanation." }}.to_jsonend@@ -307,7 +307,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json doit 'sets the status' doexpect(last_response.body).to be_json_eql('off track'.to_json)- .at_path('statusCode')+ .at_path('status')expect(last_response.body).to be_json_eql(@@ -392,7 +392,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json do{identifier: 'new_project_identifier',name: 'Project name',- statusCode: 'faulty',+ status: 'faulty',statusExplanation: "Some explanation."}.to_jsonend@@ -499,7 +499,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json docontext 'with a status' dolet(:body) do{- statusCode: 'off track',+ status: 'off track',statusExplanation: {raw: "Some explanation."}@@ -509,7 +509,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json doit 'alters the status' doexpect(last_response.body).to be_json_eql('off track'.to_json)- .at_path('statusCode')+ .at_path('status')expect(last_response.body).to be_json_eql(@@ -565,7 +565,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json docontext 'with a faulty status' dolet(:body) do{- statusCode: "bogus"+ status: "bogus"}enddiff --git a/spec/requests/api/v3/projects/create_form_resource_spec.rb b/spec/requests/api/v3/projects/create_form_resource_spec.rbindex 0a61fc27cd4..b023ce4655b 100644--- a/spec/requests/api/v3/projects/create_form_resource_spec.rb+++ b/spec/requests/api/v3/projects/create_form_resource_spec.rb@@ -106,10 +106,8 @@ describe ::API::V3::Projects::CreateFormAPI, content_type: :json do"customField#{text_custom_field.id}": {"raw": "CF text"},- status: {- code: "on track",- explanation: "A magic dwells in each beginning."- },+ status: 'on track',+ statusExplanation: "A magic dwells in each beginning.","_links": {"customField#{list_custom_field.id}": {"href": api_v3_paths.custom_option(list_custom_field.custom_options.first.id)@@ -141,17 +139,18 @@ describe ::API::V3::Projects::CreateFormAPI, content_type: :json do.to be_json_eql(api_v3_paths.custom_option(list_custom_field.custom_options.first.id).to_json).at_path("_embedded/payload/_links/customField#{list_custom_field.id}/href")+ expect(body)+ .to be_json_eql('on track'.to_json)+ .at_path('_embedded/payload/status')+expect(body).to be_json_eql({- code: "on track",- explanation: {- "format": "markdown",- "html": "<p>A magic dwells in each beginning.</p>",- "raw": "A magic dwells in each beginning."- }+ "format": "markdown",+ "html": "<p>A magic dwells in each beginning.</p>",+ "raw": "A magic dwells in each beginning."}.to_json- ).at_path("_embedded/payload/status")+ ).at_path("_embedded/payload/statusExplanation")endit 'has a commit link' do@@ -166,9 +165,7 @@ describe ::API::V3::Projects::CreateFormAPI, content_type: :json do{identifier: 'new_project_identifier',name: 'Project name',- status: {- code: "bogus"- }+ status: "bogus"}enddiff --git a/spec/requests/api/v3/projects/update_form_resource_spec.rb b/spec/requests/api/v3/projects/update_form_resource_spec.rbindex 683c429eb68..39b931d75fd 100644--- a/spec/requests/api/v3/projects/update_form_resource_spec.rb+++ b/spec/requests/api/v3/projects/update_form_resource_spec.rb@@ -167,8 +167,8 @@ describe ::API::V3::Projects::UpdateFormAPI, content_type: :json do"customField#{text_custom_field.id}": {"raw": "new CF text"},- statusCode: 'off track',- statusExplanation: 'Something goes awry.',+ status: 'off track',+ statusExplanation: { raw: 'Something goes awry.' },"_links": {"customField#{list_custom_field.id}": {"href": api_v3_paths.custom_option(list_custom_field.custom_options.last.id)@@ -202,7 +202,7 @@ describe ::API::V3::Projects::UpdateFormAPI, content_type: :json doexpect(body).to be_json_eql('off track'.to_json)- .at_path("_embedded/payload/statusCcode")+ .at_path("_embedded/payload/status")expect(body).to be_json_eql('Something goes awry.'.to_json)@@ -238,14 +238,14 @@ describe ::API::V3::Projects::UpdateFormAPI, content_type: :json docontext 'with faulty status parameters' dolet(:params) do{- statusCode: "bogus"+ status: "bogus"}endit 'displays the faulty status in the payload' doexpect(subject.body).to be_json_eql('bogus'.to_json)- .at_path('_embedded/payload/statuCcode')+ .at_path('_embedded/payload/status')endit 'has 1 validation errors' do@@ -253,7 +253,7 @@ describe ::API::V3::Projects::UpdateFormAPI, content_type: :json doendit 'has a validation error on status' do- expect(subject.body).to have_json_path('_embedded/validationErrors/statusCode')+ expect(subject.body).to have_json_path('_embedded/validationErrors/status')endit 'has no commit link' dodiff --git a/spec/services/projects/set_attributes_service_spec.rb b/spec/services/projects/set_attributes_service_spec.rbindex 6d1d4a8a718..d25b9f97030 100644--- a/spec/services/projects/set_attributes_service_spec.rb+++ b/spec/services/projects/set_attributes_service_spec.rb@@ -259,10 +259,8 @@ describe Projects::SetAttributesService, type: :model docontext 'with a value provided' dolet(:call_attributes) do{- status: {- code: 'on_track',- explanation: 'A magic dwells in each beginning.'- }+ status: 'on track',+ statusExplanation: 'A magic dwells in each beginning.'}end@@ -290,10 +288,8 @@ describe Projects::SetAttributesService, type: :model docontext 'with a value provided' dolet(:call_attributes) do{- status: {- code: 'on_track',- explanation: 'A magic dwells in each beginning.'- }+ status: 'on_track',+ statusExplanation: 'A magic dwells in each beginning.'}end@@ -316,10 +312,8 @@ describe Projects::SetAttributesService, type: :model docontext 'with an invalid code' dolet(:call_attributes) do{- status: {- code: 'bogus',- explanation: 'A magic dwells in each beginning.'- }+ status: 'bogus',+ statusExplanation: 'A magic dwells in each beginning.'}end@@ -351,10 +345,8 @@ describe Projects::SetAttributesService, type: :model docontext 'with a value provided' dolet(:call_attributes) do{- status: {- code: 'at_risk',- explanation: 'Still some magic there.'- }+ status: 'at_risk',+ statusExplanation: 'Still some magic there.'}end