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

Fix more tests

Oliver Günther25b26ef4d084
diff --git a/lib/api/v3/projects/project_representer.rb b/lib/api/v3/projects/project_representer.rb
index a9a1adfa569..56f12a33358 100644
--- a/lib/api/v3/projects/project_representer.rb
+++ b/lib/api/v3/projects/project_representer.rb
@@ -180,9 +180,7 @@ module API
}
property :status_explanation,
- writable: -> do
- represented.writable?(:status)
- end,
+ writable: -> { represented.writable?(:status) },
getter: ->(*) {
::API::Decorators::Formattable.new(status&.explanation,
object: self,
diff --git a/spec/lib/api/v3/projects/project_payload_representer_parsing_spec.rb b/spec/lib/api/v3/projects/project_payload_representer_parsing_spec.rb
index a2f538ff7c7..7c9951a7b31 100644
--- a/spec/lib/api/v3/projects/project_payload_representer_parsing_spec.rb
+++ b/spec/lib/api/v3/projects/project_payload_representer_parsing_spec.rb
@@ -43,10 +43,8 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' do
context 'status' do
let(:hash) do
{
- "status" => {
- "code" => 'on track',
- "explanation" => 'status code explanation'
- }
+ 'status' => 'on track',
+ 'statusExplanation' => { 'raw' => 'status code explanation' }
}
end
@@ -54,10 +52,7 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' do
project = representer.from_hash(hash)
expect(project.status[:code])
.to eql(:on_track)
- end
- it 'updates explanation' do
- project = representer.from_hash(hash)
expect(project.status[:explanation])
.to eql('status code explanation')
end
@@ -65,9 +60,7 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' do
context 'with code not provided' do
let(:hash) do
{
- "status" => {
- "explanation" => 'status code explanation'
- }
+ 'statusExplanation' => { 'raw' => 'status code explanation' }
}
end
@@ -87,9 +80,7 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' do
context 'with explanation not provided' do
let(:hash) do
{
- "status" => {
- "code" => 'off track'
- }
+ 'status' => 'off track'
}
end
@@ -109,23 +100,18 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' do
context 'with null for a scope' do
let(:hash) do
{
- "status" => {
- "code" => nil
- }
+ 'status' => nil
}
end
- it 'does set code to nil' do
+ it 'does set status to nil' do
project = representer.from_hash(hash).to_h
expect(project)
.to be_key(:status)
expect(project[:status])
- .to be_key(:code)
-
- expect(project[:status][:code])
- .to eql nil
+ .to be_nil
end
end
end
diff --git a/spec/lib/api/v3/projects/project_representer_spec.rb b/spec/lib/api/v3/projects/project_representer_spec.rb
index 2d5670cbd10..723314b59fe 100644
--- a/spec/lib/api/v3/projects/project_representer_spec.rb
+++ b/spec/lib/api/v3/projects/project_representer_spec.rb
@@ -120,27 +120,27 @@ describe ::API::V3::Projects::ProjectRepresenter do
end
context 'status' do
- it_behaves_like 'formattable property', :'status/explanation' do
+ it_behaves_like 'formattable property', 'statusExplanation' do
let(:value) { status.explanation }
end
it 'includes the project status code' do
expect(subject)
.to be_json_eql(status.code.tr('_', ' ').to_json)
- .at_path('status/code')
+ .at_path('status')
end
context 'if the status is nil' do
let(:status) { nil }
- it_behaves_like 'formattable property', :'status/explanation' do
+ it_behaves_like 'formattable property', 'statusExplanation' do
let(:value) { nil }
end
it 'includes the project status code' do
expect(subject)
.to be_json_eql(nil.to_json)
- .at_path('status/code')
+ .at_path('status')
end
end
end
diff --git a/spec/requests/api/v3/projects/create_form_resource_spec.rb b/spec/requests/api/v3/projects/create_form_resource_spec.rb
index b023ce4655b..d319bda5027 100644
--- a/spec/requests/api/v3/projects/create_form_resource_spec.rb
+++ b/spec/requests/api/v3/projects/create_form_resource_spec.rb
@@ -107,7 +107,7 @@ describe ::API::V3::Projects::CreateFormAPI, content_type: :json do
"raw": "CF text"
},
status: 'on track',
- statusExplanation: "A magic dwells in each beginning.",
+ statusExplanation: { raw: "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)