Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
762d6ab4
Commit
762d6ab4
authored
Mar 28, 2016
by
Abhi Rao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensuring Merge Request API returns boolean values for work_in_progress
Fixes #14692
parent
3385696b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+4
-4
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+11
-0
No files found.
app/models/merge_request.rb
View file @
762d6ab4
...
@@ -279,7 +279,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -279,7 +279,7 @@ class MergeRequest < ActiveRecord::Base
WIP_REGEX
=
/\A\s*(\[WIP\]\s*|WIP:\s*|WIP\s+)+\s*/i
.
freeze
WIP_REGEX
=
/\A\s*(\[WIP\]\s*|WIP:\s*|WIP\s+)+\s*/i
.
freeze
def
work_in_progress?
def
work_in_progress?
title
=~
WIP_REGEX
!!
(
title
=~
WIP_REGEX
)
end
end
def
wipless_title
def
wipless_title
...
...
spec/models/merge_request_spec.rb
View file @
762d6ab4
...
@@ -224,22 +224,22 @@ describe MergeRequest, models: true do
...
@@ -224,22 +224,22 @@ describe MergeRequest, models: true do
[
'WIP '
,
'WIP:'
,
'WIP: '
,
'[WIP]'
,
'[WIP] '
,
' [WIP] WIP [WIP] WIP: WIP '
].
each
do
|
wip_prefix
|
[
'WIP '
,
'WIP:'
,
'WIP: '
,
'[WIP]'
,
'[WIP] '
,
' [WIP] WIP [WIP] WIP: WIP '
].
each
do
|
wip_prefix
|
it
"detects the '
#{
wip_prefix
}
' prefix"
do
it
"detects the '
#{
wip_prefix
}
' prefix"
do
subject
.
title
=
"
#{
wip_prefix
}#{
subject
.
title
}
"
subject
.
title
=
"
#{
wip_prefix
}#{
subject
.
title
}
"
expect
(
subject
).
to
be_work_in_progress
expect
(
subject
.
work_in_progress?
).
to
eq
true
end
end
end
end
it
"doesn't detect WIP for words starting with WIP"
do
it
"doesn't detect WIP for words starting with WIP"
do
subject
.
title
=
"Wipwap
#{
subject
.
title
}
"
subject
.
title
=
"Wipwap
#{
subject
.
title
}
"
expect
(
subject
).
not_to
be_work_in_progress
expect
(
subject
.
work_in_progress?
).
to
eq
false
end
end
it
"doesn't detect WIP for words containing with WIP"
do
it
"doesn't detect WIP for words containing with WIP"
do
subject
.
title
=
"WupWipwap
#{
subject
.
title
}
"
subject
.
title
=
"WupWipwap
#{
subject
.
title
}
"
expect
(
subject
).
not_to
be_work_in_progress
expect
(
subject
.
work_in_progress?
).
to
eq
false
end
end
it
"doesn't detect WIP by default"
do
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
end
end
...
...
spec/requests/api/merge_requests_spec.rb
View file @
762d6ab4
...
@@ -118,6 +118,7 @@ describe API::API, api: true do
...
@@ -118,6 +118,7 @@ describe API::API, api: true do
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'title'
]).
to
eq
(
merge_request
.
title
)
expect
(
json_response
[
'title'
]).
to
eq
(
merge_request
.
title
)
expect
(
json_response
[
'iid'
]).
to
eq
(
merge_request
.
iid
)
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'
)
expect
(
json_response
[
'merge_status'
]).
to
eq
(
'can_be_merged'
)
end
end
...
@@ -133,6 +134,16 @@ describe API::API, api: true do
...
@@ -133,6 +134,16 @@ describe API::API, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/999"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/999"
,
user
)
expect
(
response
.
status
).
to
eq
(
404
)
expect
(
response
.
status
).
to
eq
(
404
)
end
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
end
describe
'GET /projects/:id/merge_requests/:merge_request_id/commits'
do
describe
'GET /projects/:id/merge_requests/:merge_request_id/commits'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment