Commit 05c9b9ed authored by Kerri Miller's avatar Kerri Miller Committed by Luke Duncalfe

Replace work_in_progress with draft

Replace work_in_progress with draft

Changelog: changed
parent 43ebce85
...@@ -798,6 +798,7 @@ Example response: ...@@ -798,6 +798,7 @@ Example response:
"source_project_id":35, "source_project_id":35,
"target_project_id":35, "target_project_id":35,
"labels":[ ], "labels":[ ],
"draft":false,
"work_in_progress":false, "work_in_progress":false,
"milestone":null, "milestone":null,
"merge_when_pipeline_succeeds":false, "merge_when_pipeline_succeeds":false,
......
...@@ -2080,6 +2080,7 @@ Example response: ...@@ -2080,6 +2080,7 @@ Example response:
"source_project_id": 1, "source_project_id": 1,
"target_project_id": 1, "target_project_id": 1,
"labels": [], "labels": [],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 27, "id": 27,
...@@ -2231,6 +2232,7 @@ Example response: ...@@ -2231,6 +2232,7 @@ Example response:
"closed_at": null, "closed_at": null,
"closed_by": null, "closed_by": null,
"labels": [], "labels": [],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": null, "milestone": null,
"merge_when_pipeline_succeeds": false, "merge_when_pipeline_succeeds": false,
......
...@@ -16,6 +16,7 @@ type: reference, api ...@@ -16,6 +16,7 @@ type: reference, api
> - `with_merge_status_recheck` was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/31890) in GitLab 13.0. > - `with_merge_status_recheck` was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/31890) in GitLab 13.0.
> - `reviewer_username` and `reviewer_id` were [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49341) in GitLab 13.8. > - `reviewer_username` and `reviewer_id` were [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49341) in GitLab 13.8.
> - `reviewer_ids` was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51186) in GitLab 13.8. > - `reviewer_ids` was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51186) in GitLab 13.8.
> - `draft` was [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/63473) as an eventual replacement for `work_in_progress` in GitLab 14.0
Every API call to merge requests must be authenticated. Every API call to merge requests must be authenticated.
...@@ -174,6 +175,7 @@ Parameters: ...@@ -174,6 +175,7 @@ Parameters:
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -357,6 +359,7 @@ Parameters: ...@@ -357,6 +359,7 @@ Parameters:
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -542,6 +545,7 @@ Parameters: ...@@ -542,6 +545,7 @@ Parameters:
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -680,6 +684,7 @@ Parameters: ...@@ -680,6 +684,7 @@ Parameters:
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -912,6 +917,7 @@ Parameters: ...@@ -912,6 +917,7 @@ Parameters:
"target_project_id": 4, "target_project_id": 4,
"labels": [ ], "labels": [ ],
"description": "Qui voluptatibus placeat ipsa alias quasi. Deleniti rem ut sint. Optio velit qui distinctio.", "description": "Qui voluptatibus placeat ipsa alias quasi. Deleniti rem ut sint. Optio velit qui distinctio.",
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -1122,6 +1128,7 @@ POST /projects/:id/merge_requests ...@@ -1122,6 +1128,7 @@ POST /projects/:id/merge_requests
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -1292,6 +1299,7 @@ Must include at least one non-required attribute from above. ...@@ -1292,6 +1299,7 @@ Must include at least one non-required attribute from above.
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -1477,6 +1485,7 @@ Parameters: ...@@ -1477,6 +1485,7 @@ Parameters:
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -1665,6 +1674,7 @@ Parameters: ...@@ -1665,6 +1674,7 @@ Parameters:
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -1966,6 +1976,7 @@ Example response: ...@@ -1966,6 +1976,7 @@ Example response:
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -2125,6 +2136,7 @@ Example response: ...@@ -2125,6 +2136,7 @@ Example response:
"Community contribution", "Community contribution",
"Manage" "Manage"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 5, "id": 5,
...@@ -2301,6 +2313,7 @@ Example response: ...@@ -2301,6 +2313,7 @@ Example response:
"source_project_id": 3, "source_project_id": 3,
"target_project_id": 3, "target_project_id": 3,
"labels": [], "labels": [],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 27, "id": 27,
......
...@@ -178,6 +178,7 @@ Example response: ...@@ -178,6 +178,7 @@ Example response:
"ruby", "ruby",
"tests" "tests"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 13, "id": 13,
...@@ -600,6 +601,7 @@ Example response: ...@@ -600,6 +601,7 @@ Example response:
"ruby", "ruby",
"tests" "tests"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 13, "id": 13,
...@@ -958,6 +960,7 @@ Example response: ...@@ -958,6 +960,7 @@ Example response:
"ruby", "ruby",
"tests" "tests"
], ],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 13, "id": 13,
......
...@@ -88,6 +88,7 @@ Example Response: ...@@ -88,6 +88,7 @@ Example Response:
"source_project_id": 2, "source_project_id": 2,
"target_project_id": 2, "target_project_id": 2,
"labels": [], "labels": [],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 32, "id": 32,
...@@ -161,6 +162,7 @@ Example Response: ...@@ -161,6 +162,7 @@ Example Response:
"source_project_id": 2, "source_project_id": 2,
"target_project_id": 2, "target_project_id": 2,
"labels": [], "labels": [],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 32, "id": 32,
...@@ -259,6 +261,7 @@ Example Response: ...@@ -259,6 +261,7 @@ Example Response:
"source_project_id": 2, "source_project_id": 2,
"target_project_id": 2, "target_project_id": 2,
"labels": [], "labels": [],
"draft": false,
"work_in_progress": false, "work_in_progress": false,
"milestone": { "milestone": {
"id": 32, "id": 32,
......
...@@ -36,7 +36,11 @@ module API ...@@ -36,7 +36,11 @@ module API
merge_request.labels.map(&:title).sort merge_request.labels.map(&:title).sort
end end
end end
expose :work_in_progress?, as: :work_in_progress expose :draft?, as: :draft
# [Deprecated] see draft
#
expose :draft?, as: :work_in_progress
expose :milestone, using: Entities::Milestone expose :milestone, using: Entities::Milestone
expose :merge_when_pipeline_succeeds expose :merge_when_pipeline_succeeds
......
...@@ -9,11 +9,22 @@ RSpec.describe ::API::Entities::MergeRequestBasic do ...@@ -9,11 +9,22 @@ RSpec.describe ::API::Entities::MergeRequestBasic do
let_it_be(:labels) { create_list(:label, 3) } let_it_be(:labels) { create_list(:label, 3) }
let_it_be(:merge_requests) { create_list(:labeled_merge_request, 10, :unique_branches, labels: labels) } let_it_be(:merge_requests) { create_list(:labeled_merge_request, 10, :unique_branches, labels: labels) }
let_it_be(:entity) { described_class.new(merge_request) }
# This mimics the behavior of the `Grape::Entity` serializer # This mimics the behavior of the `Grape::Entity` serializer
def present(obj) def present(obj)
described_class.new(obj).presented described_class.new(obj).presented
end end
subject { entity.as_json }
it 'includes basic fields' do
is_expected.to include(
draft: merge_request.draft?,
work_in_progress: merge_request.draft?
)
end
context "with :with_api_entity_associations scope" do context "with :with_api_entity_associations scope" do
let(:scope) { MergeRequest.with_api_entity_associations } let(:scope) { MergeRequest.with_api_entity_associations }
......
...@@ -1186,7 +1186,8 @@ RSpec.describe API::MergeRequests do ...@@ -1186,7 +1186,8 @@ RSpec.describe API::MergeRequests do
expect(json_response['downvotes']).to eq(1) expect(json_response['downvotes']).to eq(1)
expect(json_response['source_project_id']).to eq(merge_request.source_project.id) expect(json_response['source_project_id']).to eq(merge_request.source_project.id)
expect(json_response['target_project_id']).to eq(merge_request.target_project.id) expect(json_response['target_project_id']).to eq(merge_request.target_project.id)
expect(json_response['work_in_progress']).to be_falsy expect(json_response['draft']).to be false
expect(json_response['work_in_progress']).to be false
expect(json_response['merge_when_pipeline_succeeds']).to be_falsy expect(json_response['merge_when_pipeline_succeeds']).to be_falsy
expect(json_response['merge_status']).to eq('can_be_merged') expect(json_response['merge_status']).to eq('can_be_merged')
expect(json_response['should_close_merge_request']).to be_falsy expect(json_response['should_close_merge_request']).to be_falsy
...@@ -1329,22 +1330,23 @@ RSpec.describe API::MergeRequests do ...@@ -1329,22 +1330,23 @@ RSpec.describe API::MergeRequests do
expect(response).to have_gitlab_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'Work in Progress' do context 'Draft' do
let!(:merge_request_wip) do let!(:merge_request_draft) do
create(:merge_request, create(:merge_request,
author: user, author: user,
assignees: [user], assignees: [user],
source_project: project, source_project: project,
target_project: project, target_project: project,
title: "WIP: Test", title: "Draft: Test",
created_at: base_time + 1.second created_at: base_time + 1.second
) )
end end
it "returns merge request" do it "returns merge request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request_wip.iid}", user) get api("/projects/#{project.id}/merge_requests/#{merge_request_draft.iid}", user)
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['draft']).to eq(true)
expect(json_response['work_in_progress']).to eq(true) expect(json_response['work_in_progress']).to eq(true)
end end
end end
...@@ -2522,8 +2524,8 @@ RSpec.describe API::MergeRequests do ...@@ -2522,8 +2524,8 @@ RSpec.describe API::MergeRequests do
expect(json_response['message']).to eq('405 Method Not Allowed') expect(json_response['message']).to eq('405 Method Not Allowed')
end end
it "returns 405 if merge_request is a work in progress" do it "returns 405 if merge_request is a draft" do
merge_request.update_attribute(:title, "WIP: #{merge_request.title}") merge_request.update_attribute(:title, "Draft: #{merge_request.title}")
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user) put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(:method_not_allowed) expect(response).to have_gitlab_http_status(:method_not_allowed)
expect(json_response['message']).to eq('405 Method Not Allowed') expect(json_response['message']).to eq('405 Method Not Allowed')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment