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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
c7b425a3
Commit
c7b425a3
authored
Feb 09, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark as WIP based on MR commits only
parent
75244061
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
10 deletions
+37
-10
app/services/merge_requests/refresh_service.rb
app/services/merge_requests/refresh_service.rb
+5
-1
spec/services/merge_requests/refresh_service_spec.rb
spec/services/merge_requests/refresh_service_spec.rb
+32
-9
No files found.
app/services/merge_requests/refresh_service.rb
View file @
c7b425a3
...
@@ -144,7 +144,11 @@ module MergeRequests
...
@@ -144,7 +144,11 @@ module MergeRequests
return
unless
@commits
.
present?
return
unless
@commits
.
present?
merge_requests_for_source_branch
.
each
do
|
merge_request
|
merge_requests_for_source_branch
.
each
do
|
merge_request
|
wip_commit
=
@commits
.
detect
(
&
:work_in_progress?
)
commit_shas
=
merge_request
.
commits_sha
wip_commit
=
@commits
.
detect
do
|
commit
|
commit
.
work_in_progress?
&&
commit_shas
.
include?
(
commit
.
sha
)
end
if
wip_commit
&&
!
merge_request
.
work_in_progress?
if
wip_commit
&&
!
merge_request
.
work_in_progress?
merge_request
.
update
(
title:
merge_request
.
wip_title
)
merge_request
.
update
(
title:
merge_request
.
wip_title
)
...
...
spec/services/merge_requests/refresh_service_spec.rb
View file @
c7b425a3
...
@@ -287,41 +287,64 @@ describe MergeRequests::RefreshService, services: true do
...
@@ -287,41 +287,64 @@ describe MergeRequests::RefreshService, services: true do
it
'references the commit that caused the Work in Progress status'
do
it
'references the commit that caused the Work in Progress status'
do
refresh_service
.
execute
(
@oldrev
,
@newrev
,
'refs/heads/master'
)
refresh_service
.
execute
(
@oldrev
,
@newrev
,
'refs/heads/master'
)
allow
(
refresh_service
).
to
receive
(
:find_new_commits
)
allow
(
refresh_service
).
to
receive
(
:find_new_commits
)
refresh_service
.
instance_variable_set
(
"@commits"
,
[
refresh_service
.
instance_variable_set
(
"@commits"
,
[
instance_double
(
double
(
Commit
,
id:
'aaaaaaa'
,
id:
'aaaaaaa'
,
sha:
'38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e'
,
short_id:
'aaaaaaa'
,
short_id:
'aaaaaaa'
,
title:
'Fix issue'
,
title:
'Fix issue'
,
work_in_progress?:
false
work_in_progress?:
false
),
),
instance_double
(
double
(
Commit
,
id:
'bbbbbbb'
,
id:
'bbbbbbb'
,
sha:
'498214de67004b1da3d820901307bed2a68a8ef6'
,
short_id:
'bbbbbbb'
,
short_id:
'bbbbbbb'
,
title:
'fixup! Fix issue'
,
title:
'fixup! Fix issue'
,
work_in_progress?:
true
,
work_in_progress?:
true
,
to_reference:
'bbbbbbb'
to_reference:
'bbbbbbb'
),
),
instance_double
(
double
(
Commit
,
id:
'ccccccc'
,
id:
'ccccccc'
,
sha:
'1b12f15a11fc6e62177bef08f47bc7b5ce50b141'
,
short_id:
'ccccccc'
,
short_id:
'ccccccc'
,
title:
'fixup! Fix issue'
,
title:
'fixup! Fix issue'
,
work_in_progress?:
true
,
work_in_progress?:
true
,
to_reference:
'ccccccc'
to_reference:
'ccccccc'
),
),
])
])
refresh_service
.
execute
(
@oldrev
,
@newrev
,
'refs/heads/wip'
)
refresh_service
.
execute
(
@oldrev
,
@newrev
,
'refs/heads/wip'
)
reload_mrs
reload_mrs
expect
(
@merge_request
.
notes
.
last
.
note
).
to
eq
(
expect
(
@merge_request
.
notes
.
last
.
note
).
to
eq
(
"marked as a **Work In Progress** from bbbbbbb"
"marked as a **Work In Progress** from bbbbbbb"
)
)
end
end
it
'does not mark as WIP based on commits that do not belong to an MR'
do
allow
(
refresh_service
).
to
receive
(
:find_new_commits
)
refresh_service
.
instance_variable_set
(
"@commits"
,
[
double
(
id:
'aaaaaaa'
,
sha:
'aaaaaaa'
,
short_id:
'aaaaaaa'
,
title:
'Fix issue'
,
work_in_progress?:
false
),
double
(
id:
'bbbbbbb'
,
sha:
'bbbbbbbb'
,
short_id:
'bbbbbbb'
,
title:
'fixup! Fix issue'
,
work_in_progress?:
true
,
to_reference:
'bbbbbbb'
)
])
refresh_service
.
execute
(
@oldrev
,
@newrev
,
'refs/heads/master'
)
reload_mrs
expect
(
@merge_request
.
work_in_progress?
).
to
be_falsey
end
end
end
def
reload_mrs
def
reload_mrs
...
...
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