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
Tatuya Kamada
gitlab-ce
Commits
b91d1890
Commit
b91d1890
authored
Feb 10, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass current_user to merge_request.closes_issues in API ans streamline MR API specs
parent
78e36780
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
19 deletions
+9
-19
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+1
-1
spec/factories/merge_requests.rb
spec/factories/merge_requests.rb
+0
-6
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+8
-12
No files found.
lib/api/merge_requests.rb
View file @
b91d1890
...
@@ -310,7 +310,7 @@ module API
...
@@ -310,7 +310,7 @@ module API
# GET /projects/:id/merge_requests/:merge_request_id/closes_issues
# GET /projects/:id/merge_requests/:merge_request_id/closes_issues
get
"
#{
path
}
/closes_issues"
do
get
"
#{
path
}
/closes_issues"
do
merge_request
=
user_project
.
merge_requests
.
find
(
params
[
:merge_request_id
])
merge_request
=
user_project
.
merge_requests
.
find
(
params
[
:merge_request_id
])
issues
=
::
Kaminari
.
paginate_array
(
merge_request
.
closes_issues
)
issues
=
::
Kaminari
.
paginate_array
(
merge_request
.
closes_issues
(
current_user
)
)
present
paginate
(
issues
),
with:
Entities
::
Issue
present
paginate
(
issues
),
with:
Entities
::
Issue
end
end
end
end
...
...
spec/factories/merge_requests.rb
View file @
b91d1890
...
@@ -73,12 +73,6 @@ FactoryGirl.define do
...
@@ -73,12 +73,6 @@ FactoryGirl.define do
merge_user
author
merge_user
author
end
end
trait
:with_closes_issues
do
source_branch
"markdown"
target_branch
"master"
state
:opened
end
factory
:closed_merge_request
,
traits:
[
:closed
]
factory
:closed_merge_request
,
traits:
[
:closed
]
factory
:reopened_merge_request
,
traits:
[
:reopened
]
factory
:reopened_merge_request
,
traits:
[
:reopened
]
factory
:merge_request_with_diffs
,
traits:
[
:with_diffs
]
factory
:merge_request_with_diffs
,
traits:
[
:with_diffs
]
...
...
spec/requests/api/merge_requests_spec.rb
View file @
b91d1890
...
@@ -448,25 +448,21 @@ describe API::API, api: true do
...
@@ -448,25 +448,21 @@ describe API::API, api: true do
end
end
end
end
describe
"GET :id/merge_requests/:merge_request_id/closes_issues"
do
describe
'GET :id/merge_requests/:merge_request_id/closes_issues'
do
let
(
:merge_request_with_closes_issues
)
{
create
(
:merge_request
,
:with_closes_issues
,
author:
user
,
assignee:
user
,
source_project:
project
,
target_project:
project
,
title:
"Closed #
#{
issue
.
id
}
"
,
created_at:
base_time
+
3
.
seconds
,
description:
"This should close #
#{
issue
.
iid
}
"
)
}
it
'returns the issue that will be closed on merge'
do
let
(
:issue
)
do
issue
=
create
(
:issue
,
project:
project
)
create
:issue
,
mr
=
merge_request
.
tap
do
|
mr
|
author:
user
,
mr
.
update_attribute
(
:description
,
"Closes
#{
issue
.
to_reference
(
mr
.
project
)
}
"
)
assignee:
user
,
project:
project
,
milestone:
nil
end
end
it
"should return the issues that will be closed on merge"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
mr
.
id
}
/closes_issues"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request_with_closes_issues
.
id
}
/closes_issues"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
it
"should return an empty array when there are no issues to be closed"
do
it
'returns an empty array when there are no issues to be closed'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/closes_issues"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/closes_issues"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
...
...
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