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
0d5290a8
Commit
0d5290a8
authored
May 17, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use symbols instead strings on controller service result flow
parent
9fbd168f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
app/controllers/projects/related_issues_controller.rb
app/controllers/projects/related_issues_controller.rb
+3
-3
spec/controllers/projects/related_issues_controller_spec.rb
spec/controllers/projects/related_issues_controller_spec.rb
+3
-3
No files found.
app/controllers/projects/related_issues_controller.rb
View file @
0d5290a8
...
...
@@ -11,10 +11,10 @@ module Projects
opts
=
params
.
slice
(
:issue_references
)
result
=
RelatedIssues
::
CreateService
.
new
(
issue
,
current_user
,
opts
).
execute
if
result
[
'status'
]
==
:success
render
json:
{
result:
result
,
issues:
issues
},
status:
result
[
'http_status'
]
if
result
[
:status
]
==
:success
render
json:
{
result:
result
,
issues:
issues
},
status:
result
[
:http_status
]
else
render
json:
{
result:
result
},
status:
result
[
'http_status'
]
render
json:
{
result:
result
},
status:
result
[
:http_status
]
end
end
...
...
spec/controllers/projects/related_issues_controller_spec.rb
View file @
0d5290a8
...
...
@@ -34,7 +34,7 @@ describe Projects::RelatedIssuesController, type: :controller do
describe
'POST #create'
do
let
(
:service
)
{
double
(
RelatedIssues
::
CreateService
,
execute:
service_response
)
}
let
(
:list_service
)
{
double
(
RelatedIssues
::
ListService
,
execute:
list_service_response
)
}
let
(
:service_response
)
{
{
'message'
=>
'yay'
,
'status'
=>
:success
}
}
let
(
:service_response
)
{
{
message:
'yay'
,
status:
:success
}
}
let
(
:list_service_response
)
{
[{
'foo'
=>
'bar'
}]
}
let
(
:issue_references
)
{
double
}
let
(
:user_role
)
{
:developer
}
...
...
@@ -78,11 +78,11 @@ describe Projects::RelatedIssuesController, type: :controller do
end
context
'when failing service result'
do
let
(
:service_response
)
{
{
'http_status'
=>
401
,
'status'
=>
'error'
}
}
let
(
:service_response
)
{
{
http_status:
401
,
status:
'error'
}
}
it
'returns failure JSON'
do
is_expected
.
to
have_http_status
(
401
)
expect
(
json_response
).
to
eq
(
'result'
=>
service_response
)
expect
(
json_response
).
to
eq
(
'result'
=>
{
'http_status'
=>
401
,
'status'
=>
'error'
}
)
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