Commit 6f45a89b authored by Robert Speicher's avatar Robert Speicher Committed by Rémy Coutable

Merge branch 'fix_wip_in_mr_api' into 'master'

Ensuring Merge Request API returns boolean values for work_in_progress

Fixes #14692.

See merge request !3432
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent eceaa30b
......@@ -4,6 +4,7 @@ v 8.6.3 (unreleased)
- Destroy related todos when an Issue/MR is deleted. !3376
- Fix error 500 when target is nil on todo list. !3376
- Fix copying uploads when moving issue to another project. !3382
- Ensuring Merge Request API returns boolean values for work_in_progress (Abhi Rao). !3432
- Fix raw/rendered diff producing different results on merge requests. !3450
- Fix commit comment alignment (Stan Hu). !3466
- Update gitlab-shell version and doc to 2.6.12. gitlab-org/gitlab-ee!280
......
......@@ -279,7 +279,7 @@ class MergeRequest < ActiveRecord::Base
WIP_REGEX = /\A\s*(\[WIP\]\s*|WIP:\s*|WIP\s+)+\s*/i.freeze
def work_in_progress?
title =~ WIP_REGEX
!!(title =~ WIP_REGEX)
end
def wipless_title
......
......@@ -224,22 +224,22 @@ describe MergeRequest, models: true do
['WIP ', 'WIP:', 'WIP: ', '[WIP]', '[WIP] ', ' [WIP] WIP [WIP] WIP: WIP '].each do |wip_prefix|
it "detects the '#{wip_prefix}' prefix" do
subject.title = "#{wip_prefix}#{subject.title}"
expect(subject).to be_work_in_progress
expect(subject.work_in_progress?).to eq true
end
end
it "doesn't detect WIP for words starting with WIP" do
subject.title = "Wipwap #{subject.title}"
expect(subject).not_to be_work_in_progress
expect(subject.work_in_progress?).to eq false
end
it "doesn't detect WIP for words containing with WIP" do
subject.title = "WupWipwap #{subject.title}"
expect(subject).not_to be_work_in_progress
expect(subject.work_in_progress?).to eq false
end
it "doesn't detect WIP by default" do
expect(subject).not_to be_work_in_progress
expect(subject.work_in_progress?).to eq false
end
end
......
......@@ -118,6 +118,7 @@ describe API::API, api: true do
expect(response.status).to eq(200)
expect(json_response['title']).to eq(merge_request.title)
expect(json_response['iid']).to eq(merge_request.iid)
expect(json_response['work_in_progress']).to eq(false)
expect(json_response['merge_status']).to eq('can_be_merged')
end
......@@ -133,6 +134,16 @@ describe API::API, api: true do
get api("/projects/#{project.id}/merge_requests/999", user)
expect(response.status).to eq(404)
end
context 'Work in Progress' do
let!(:merge_request_wip) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "WIP: Test", created_at: base_time + 1.second) }
it "should return merge_request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request_wip.id}", user)
expect(response.status).to eq(200)
expect(json_response['work_in_progress']).to eq(true)
end
end
end
describe 'GET /projects/:id/merge_requests/:merge_request_id/commits' do
......
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