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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
258e4e97
Commit
258e4e97
authored
Apr 25, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use CreateRelatedIssueService on RelatedIssuesController#create
parent
086ad4d7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
7 deletions
+46
-7
app/controllers/projects/related_issues_controller.rb
app/controllers/projects/related_issues_controller.rb
+5
-1
spec/controllers/projects/related_issues_controller_spec.rb
spec/controllers/projects/related_issues_controller_spec.rb
+41
-6
No files found.
app/controllers/projects/related_issues_controller.rb
View file @
258e4e97
...
...
@@ -2,13 +2,17 @@ module Projects
class
RelatedIssuesController
<
ApplicationController
include
IssuesHelper
before_action
:authorize_read_issue!
,
only:
[
:index
]
before_action
:authorize_read_issue!
,
only:
[
:index
,
:create
]
def
index
render
json:
serialize_as_json
end
def
create
opts
=
{
issue_references:
params
[
:issue_references
]
}
result
=
CreateRelatedIssueService
.
new
(
issue
,
current_user
,
opts
).
execute
render
json:
result
,
status:
result
[
'http_status'
]
end
private
...
...
spec/controllers/projects/related_issues_controller_spec.rb
View file @
258e4e97
...
...
@@ -5,7 +5,7 @@ describe Projects::RelatedIssuesController, type: :controller do
let
(
:project
)
{
create
(
:project_empty_repo
)
}
let
(
:issue
)
{
create
:issue
,
project:
project
}
describe
"GET #index"
do
describe
'GET #index'
do
let
(
:issue_b
)
{
create
:issue
,
project:
project
}
let
(
:issue_c
)
{
create
:issue
,
project:
project
}
let
(
:issue_d
)
{
create
:issue
,
project:
project
}
...
...
@@ -28,7 +28,7 @@ describe Projects::RelatedIssuesController, type: :controller do
created_at:
Date
.
today
)
end
it
"returns related issues JSON"
do
it
'returns related issues JSON'
do
sign_in
user
project
.
team
<<
[
user
,
:developer
]
...
...
@@ -70,10 +70,45 @@ describe Projects::RelatedIssuesController, type: :controller do
end
end
xdescribe
"GET #create"
do
it
"returns http success"
do
get
:create
expect
(
response
).
to
have_http_status
(
:success
)
describe
'POST #create'
do
let
(
:service
)
{
double
(
CreateRelatedIssueService
,
execute:
service_response
)
}
let
(
:service_response
)
{
{
'message'
=>
'yay'
}
}
let
(
:issue_references
)
{
double
}
before
do
project
.
team
<<
[
user
,
:developer
]
allow
(
CreateRelatedIssueService
).
to
receive
(
:new
)
.
with
(
issue
,
user
,
{
issue_references:
issue_references
})
.
and_return
(
service
)
end
subject
do
sign_in
user
post
:create
,
namespace_id:
issue
.
project
.
namespace
,
project_id:
issue
.
project
,
issue_id:
issue
,
issue_references:
issue_references
,
format: :json
end
context
'with success'
do
it
'returns success JSON'
do
is_expected
.
to
have_http_status
(
200
)
expect
(
json_response
).
to
eq
(
service_response
)
end
end
context
'with failure'
do
context
'when failure service result'
do
let
(
:service_response
)
{
{
'http_status'
=>
401
}
}
it
'returns failure JSON'
do
is_expected
.
to
have_http_status
(
401
)
expect
(
json_response
).
to
eq
(
service_response
)
end
end
end
end
end
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