BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d368b2d2
Commit
d368b2d2
authored
Aug 17, 2017
by
haseeb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved merge parms to service
parent
59d7ffad
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
32 deletions
+16
-32
issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-11
create_from_issue_service.rb
app/services/merge_requests/create_from_issue_service.rb
+4
-1
create_from_issue_service_spec.rb
...services/merge_requests/create_from_issue_service_spec.rb
+11
-20
No files found.
app/controllers/projects/issues_controller.rb
View file @
d368b2d2
...
...
@@ -212,7 +212,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
def
create_merge_request
result
=
::
MergeRequests
::
CreateFromIssueService
.
new
(
project
,
current_user
,
merge_request_params
).
execute
result
=
::
MergeRequests
::
CreateFromIssueService
.
new
(
project
,
current_user
,
issue_iid:
issue
.
iid
).
execute
if
result
[
:status
]
==
:success
render
json:
MergeRequestCreateSerializer
.
new
.
represent
(
result
[
:merge_request
])
...
...
@@ -287,14 +287,4 @@ class Projects::IssuesController < Projects::ApplicationController
redirect_to
new_user_session_path
,
notice:
notice
end
private
def
merge_request_params
{
issue_iid:
issue
.
iid
,
label_ids:
issue
.
label_ids
,
milestone_id:
issue
.
milestone_id
}
end
end
app/services/merge_requests/create_from_issue_service.rb
View file @
d368b2d2
...
...
@@ -3,6 +3,8 @@ module MergeRequests
def
execute
return
error
(
'Invalid issue iid'
)
unless
issue_iid
.
present?
&&
issue
.
present?
params
[
:label_ids
]
=
issue
.
label_ids
if
issue
.
label_ids
.
any?
result
=
CreateBranchService
.
new
(
project
,
current_user
).
execute
(
branch_name
,
ref
)
return
result
if
result
[
:status
]
==
:error
...
...
@@ -43,7 +45,8 @@ module MergeRequests
{
source_project_id:
project
.
id
,
source_branch:
branch_name
,
target_project_id:
project
.
id
target_project_id:
project
.
id
,
milestone_id:
issue
.
milestone_id
}
end
...
...
spec/services/merge_requests/create_from_issue_service_spec.rb
View file @
d368b2d2
...
...
@@ -3,22 +3,11 @@ require 'spec_helper'
describe
MergeRequests
::
CreateFromIssueService
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:
issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:
labels
)
{
create_pair
(
:label
,
project:
project
)
}
let
(
:
label_ids
)
{
create_pair
(
:label
,
project:
project
).
map
(
&
:id
)
}
let
(
:milestone
_id
)
{
create
(
:milestone
,
project:
project
).
id
}
let
(
:
issue
)
{
create
(
:issue
,
project:
project
,
milestone_id:
milestone_id
)
}
subject
(
:service
)
{
described_class
.
new
(
project
,
user
,
issue_iid:
issue
.
iid
)
}
subject
(
:service2
)
do
described_class
.
new
(
project
,
user
,
{
issue_iid:
issue
.
iid
,
milestone_id:
milestone
.
id
,
label_ids:
labels
.
map
(
&
:id
)
}
)
end
before
do
project
.
add_developer
(
user
)
...
...
@@ -38,16 +27,18 @@ describe MergeRequests::CreateFromIssueService do
described_class
.
new
(
project
,
user
,
issue_iid:
-
1
).
execute
end
it
"can inherit labels"
do
result
=
service2
.
execute
it
"inherits labels"
do
issue
.
assign_attributes
(
label_ids:
label_ids
)
result
=
service
.
execute
expect
(
result
[
:merge_request
].
label_ids
).
to
eq
(
label
s
.
map
(
&
:id
)
)
expect
(
result
[
:merge_request
].
label_ids
).
to
eq
(
label
_ids
)
end
it
"
can inherit
milestones"
do
result
=
service
2
.
execute
it
"
inherits
milestones"
do
result
=
service
.
execute
expect
(
result
[
:merge_request
].
milestone_id
).
to
eq
(
milestone
.
id
)
expect
(
result
[
:merge_request
].
milestone_id
).
to
eq
(
milestone
_
id
)
end
it
'delegates the branch creation to CreateBranchService'
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