From 45d5b7f557952b555865a6a838b7e1315722bb86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saray=20Cabrera=20Padr=C3=B3n?= Date: Fri, 8 Nov 2019 16:58:12 +0100 Subject: [PATCH] Re-organize staging projects XML results The "requests_to_review" group has been removed, it contains redundant data. Untracked requests, obsolete requests and missing reviews have been moved from "status" scope to "requests" scope. So they are shown when retrieving staging projects via API with 'requests=1' and not with 'status=1'. Related tests and API doc has been updated. --- docs/api/api/api.txt | 4 +- .../_staging_project_item.xml.builder | 9 ++--- .../staging_projects_controller_spec.rb | 37 +++++++++---------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/docs/api/api/api.txt b/docs/api/api/api.txt index 155955a3d3c..f11b7ebda6c 100644 --- a/docs/api/api/api.txt +++ b/docs/api/api/api.txt @@ -1944,7 +1944,7 @@ GET /staging//staging_projects?requests=1&status=1&his Get the overall state of all staging projects belonging to a staging workflow project. Extra information can be requested by adding any combination of these parameters in the URL: requests, status and history. - - If requests is present, the output includes the staged requests. + - If requests is present, the output includes the staged, untracked and obsole requests as well as missing reviews. - If status is present, the output includes the overall state and the status xml (broken packages, missing reviews, checks, etc.) - If history is present, the output includes the history of the staging project. @@ -1954,7 +1954,7 @@ GET /staging//staging_projects/?reque Get the overall state of a staging project. Extra information can be requested by adding any combination of these parameters in the URL: requests, status and history. - - If requests is present, the output includes the staged requests. + - If requests is present, the output includes the staged, untracked and obsole requests as well as missing reviews. - If status is present, the output includes the overall state and the status xml (broken packages, missing reviews, checks, etc.) - If history is present, the output includes the history of the staging project. diff --git a/src/api/app/views/staging/staging_projects/_staging_project_item.xml.builder b/src/api/app/views/staging/staging_projects/_staging_project_item.xml.builder index d64e281cf6f..030bdd72436 100644 --- a/src/api/app/views/staging/staging_projects/_staging_project_item.xml.builder +++ b/src/api/app/views/staging/staging_projects/_staging_project_item.xml.builder @@ -6,21 +6,18 @@ builder.staging_project(attributes) do builder.staged_requests(count: staging_project.staged_requests.count) do render(partial: 'staging/shared/requests', locals: { requests: staging_project.staged_requests, builder: builder }) end - end - - if options[:status] builder.untracked_requests(count: staging_project.untracked_requests.count) do render(partial: 'staging/shared/requests', locals: { requests: staging_project.untracked_requests, builder: builder }) end - builder.requests_to_review(count: staging_project.requests_to_review.count) do - render(partial: 'staging/shared/requests', locals: { requests: staging_project.requests_to_review, builder: builder }) - end builder.obsolete_requests(count: staging_project.staged_requests.obsolete.count) do render(partial: 'staging/shared/requests', locals: { requests: staging_project.staged_requests.obsolete, builder: builder }) end render(partial: 'missing_reviews', locals: { missing_reviews: staging_project.missing_reviews, count: staging_project.missing_reviews.count, builder: builder }) + end + + if options[:status] render(partial: 'building_repositories', locals: { building_repositories: staging_project.building_repositories, count: staging_project.building_repositories.count, builder: builder }) diff --git a/src/api/spec/controllers/staging/staging_projects_controller_spec.rb b/src/api/spec/controllers/staging/staging_projects_controller_spec.rb index 777642d9a41..69fcb9d2563 100644 --- a/src/api/spec/controllers/staging/staging_projects_controller_spec.rb +++ b/src/api/spec/controllers/staging/staging_projects_controller_spec.rb @@ -101,15 +101,16 @@ assert_select 'staging_project' do assert_select 'staged_requests', 0 assert_select 'untracked_requests', 0 - assert_select 'requests_to_review', 0 + assert_select 'obsolete_requests', 0 assert_select 'missing_reviews', 0 assert_select 'broken_packages', 0 + assert_select 'checks', 0 assert_select 'history', 0 end end end - context 'with staged requests' do + context 'with requests' do before do get :show, params: { staging_workflow_project: staging_workflow.project.name, staging_project_name: staging_project.name, requests: 1, format: :xml } @@ -119,15 +120,20 @@ it { expect(response.body).not_to include("