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
9ccd8b87
Commit
9ccd8b87
authored
Feb 28, 2017
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate the Todos API to use `issuable_iid`
- Instead of `issuable_id`
parent
70584e69
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
lib/api/todos.rb
lib/api/todos.rb
+4
-4
spec/requests/api/todos_spec.rb
spec/requests/api/todos_spec.rb
+3
-3
No files found.
lib/api/todos.rb
View file @
9ccd8b87
...
...
@@ -5,8 +5,8 @@ module API
before
{
authenticate!
}
ISSUABLE_TYPES
=
{
'merge_requests'
=>
->
(
i
d
)
{
find_merge_request_with_access
(
id
)
},
'issues'
=>
->
(
i
d
)
{
find_project_issue
(
id
)
}
'merge_requests'
=>
->
(
i
id
)
{
find_merge_request_with_access
(
i
id
)
},
'issues'
=>
->
(
i
id
)
{
find_project_issue
(
i
id
)
}
}.
freeze
params
do
...
...
@@ -14,13 +14,13 @@ module API
end
resource
:projects
do
ISSUABLE_TYPES
.
each
do
|
type
,
finder
|
type_id_str
=
"
#{
type
.
singularize
}
_id"
.
to_sym
type_id_str
=
"
#{
type
.
singularize
}
_i
i
d"
.
to_sym
desc
'Create a todo on an issuable'
do
success
Entities
::
Todo
end
params
do
requires
type_id_str
,
type:
Integer
,
desc:
'The ID of an issuable'
requires
type_id_str
,
type:
Integer
,
desc:
'The I
I
D of an issuable'
end
post
":id/
#{
type
}
/:
#{
type_id_str
}
/todo"
do
issuable
=
instance_exec
(
params
[
type_id_str
],
&
finder
)
...
...
spec/requests/api/todos_spec.rb
View file @
9ccd8b87
...
...
@@ -163,7 +163,7 @@ describe API::Todos, api: true do
shared_examples
'an issuable'
do
|
issuable_type
|
it
'creates a todo on an issuable'
do
post
api
(
"/projects/
#{
project_1
.
id
}
/
#{
issuable_type
}
/
#{
issuable
.
id
}
/todo"
,
john_doe
)
post
api
(
"/projects/
#{
project_1
.
id
}
/
#{
issuable_type
}
/
#{
issuable
.
i
i
d
}
/todo"
,
john_doe
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'project'
]).
to
be_a
Hash
...
...
@@ -180,7 +180,7 @@ describe API::Todos, api: true do
it
'returns 304 there already exist a todo on that issuable'
do
create
(
:todo
,
project:
project_1
,
author:
author_1
,
user:
john_doe
,
target:
issuable
)
post
api
(
"/projects/
#{
project_1
.
id
}
/
#{
issuable_type
}
/
#{
issuable
.
id
}
/todo"
,
john_doe
)
post
api
(
"/projects/
#{
project_1
.
id
}
/
#{
issuable_type
}
/
#{
issuable
.
i
i
d
}
/todo"
,
john_doe
)
expect
(
response
.
status
).
to
eq
(
304
)
end
...
...
@@ -195,7 +195,7 @@ describe API::Todos, api: true do
guest
=
create
(
:user
)
project_1
.
team
<<
[
guest
,
:guest
]
post
api
(
"/projects/
#{
project_1
.
id
}
/
#{
issuable_type
}
/
#{
issuable
.
id
}
/todo"
,
guest
)
post
api
(
"/projects/
#{
project_1
.
id
}
/
#{
issuable_type
}
/
#{
issuable
.
i
i
d
}
/todo"
,
guest
)
if
issuable_type
==
'merge_requests'
expect
(
response
).
to
have_http_status
(
403
)
...
...
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