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
Adapt backend tests for separated attributes
Oliver Günthera2ede60dd3ef
diff --git a/lib/api/v3/projects/schemas/project_schema_representer.rb b/lib/api/v3/projects/schemas/project_schema_representer.rbindex dbd27ad77ca..d90cdbafa2b 100644--- a/lib/api/v3/projects/schemas/project_schema_representer.rb+++ b/lib/api/v3/projects/schemas/project_schema_representer.rb@@ -67,12 +67,14 @@ module APIschema :status_code,type: 'ProjectStatus',+ name_source: ->(*) { I18n.t('activerecord.attributes.project/status.code') },visibility: false,required: false,writable: ->(*) { represented.writable?(:status) }schema :status_explanation,type: 'Formattable',+ name_source: ->(*) { I18n.t('activerecord.attributes.project/status.explanation') },visibility: false,required: false,writable: ->(*) { represented.writable?(:status) }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 d6e1bbf688f..71d927698b0 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@@ -179,13 +179,24 @@ describe ::API::V3::Projects::Schemas::ProjectSchemaRepresenter doit_behaves_like 'has no visibility property'end- describe 'status' do+ describe 'statusExplanation' do+ let(:path) { 'statusExplanation' }++ it_behaves_like 'has basic schema properties' do+ let(:type) { 'Formattible' }+ let(:name) { I18n.t('activerecord.attributes.project/status.explanation') }+ let(:required) { false }+ let(:writable) { true }+ end+ end++ describe 'statusCode' dolet(:path) { 'status' }it_behaves_like 'has basic schema properties' dolet(:type) { 'ProjectStatus' }- let(:name) { I18n.t('attributes.status') }- let(:required) { true }+ let(:name) { I18n.t('activerecord.attributes.project/status.code') }+ let(:required) { false }let(:writable) { true }enddiff --git a/spec/requests/api/v3/project_resource_spec.rb b/spec/requests/api/v3/project_resource_spec.rbindex 954e50deca6..c1daf9fc741 100644--- a/spec/requests/api/v3/project_resource_spec.rb+++ b/spec/requests/api/v3/project_resource_spec.rb@@ -107,11 +107,11 @@ describe 'API v3 Project resource', type: :request, content_type: :json doit 'includes the project status' doexpect(subject.body).to be_json_eql(project_status.explanation.to_json)- .at_path("status/explanation/raw")+ .at_path("statusExplanation/raw")expect(subject.body).to be_json_eql(project_status.code.tr('_', ' ').to_json)- .at_path("status/code")+ .at_path("statusCode")endcontext 'requesting nonexistent project' do@@ -299,26 +299,25 @@ describe 'API v3 Project resource', type: :request, content_type: :json do{identifier: 'new_project_identifier',name: 'Project name',- status: {- "code": "off track",- "explanation": "Some explanation."- }+ statusCode: 'off track',+ statusExplanation: { raw: "Some explanation." }}.to_jsonendit 'sets the status' do+ expect(last_response.body)+ .to be_json_eql('off track'.to_json)+ .at_path('statusCode')+expect(last_response.body).to be_json_eql({- "code": "off track",- "explanation": {- "format": "markdown",- "html": "<p>Some explanation.</p>",- "raw": "Some explanation."- }+ "format": "markdown",+ "html": "<p>Some explanation.</p>",+ "raw": "Some explanation."}.to_json)- .at_path("status")+ .at_path("statusExplanation")endit 'creates a project and a status' do@@ -393,10 +392,8 @@ describe 'API v3 Project resource', type: :request, content_type: :json do{identifier: 'new_project_identifier',name: 'Project name',- status: {- "code": "faulty",- "explanation": "Some explanation."- }+ statusCode: 'faulty',+ statusExplanation: "Some explanation."}.to_jsonend@@ -502,26 +499,27 @@ describe 'API v3 Project resource', type: :request, content_type: :json docontext 'with a status' dolet(:body) do{- status: {- "code": "off track",- "explanation": "Some explanation."+ statusCode: 'off track',+ statusExplanation: {+ raw: "Some explanation."}}endit 'alters the status' do+ expect(last_response.body)+ .to be_json_eql('off track'.to_json)+ .at_path('statusCode')+expect(last_response.body).to be_json_eql({- "code": "off track",- "explanation": {- "format": "markdown",- "html": "<p>Some explanation.</p>",- "raw": "Some explanation."- }+ "format": "markdown",+ "html": "<p>Some explanation.</p>",+ "raw": "Some explanation."}.to_json)- .at_path("status")+ .at_path("statusExplanation")endit 'persists the altered status' do@@ -567,9 +565,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json docontext 'with a faulty status' dolet(:body) do{- status: {- "code": "bogus"- }+ statusCode: "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 5bc4bdcea9e..683c429eb68 100644--- a/spec/requests/api/v3/projects/update_form_resource_spec.rb+++ b/spec/requests/api/v3/projects/update_form_resource_spec.rb@@ -167,10 +167,8 @@ describe ::API::V3::Projects::UpdateFormAPI, content_type: :json do"customField#{text_custom_field.id}": {"raw": "new CF text"},- status: {- code: "off track",- explanation: "Something goes awry."- },+ statusCode: 'off track',+ statusExplanation: 'Something goes awry.',"_links": {"customField#{list_custom_field.id}": {"href": api_v3_paths.custom_option(list_custom_field.custom_options.last.id)@@ -204,11 +202,11 @@ describe ::API::V3::Projects::UpdateFormAPI, content_type: :json doexpect(body).to be_json_eql('off track'.to_json)- .at_path("_embedded/payload/status/code")+ .at_path("_embedded/payload/statusCcode")expect(body).to be_json_eql('Something goes awry.'.to_json)- .at_path("_embedded/payload/status/explanation/raw")+ .at_path("_embedded/payload/statusExplanation/raw")endit 'has a commit link' do@@ -240,16 +238,14 @@ describe ::API::V3::Projects::UpdateFormAPI, content_type: :json docontext 'with faulty status parameters' dolet(:params) do{- status: {- code: "bogus"- }+ statusCode: "bogus"}endit 'displays the faulty status in the payload' doexpect(subject.body).to be_json_eql('bogus'.to_json)- .at_path('_embedded/payload/status/code')+ .at_path('_embedded/payload/statuCcode')endit 'has 1 validation errors' do@@ -257,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/status')+ expect(subject.body).to have_json_path('_embedded/validationErrors/statusCode')endit 'has no commit link' do