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
5b29f066
Commit
5b29f066
authored
Feb 13, 2019
by
Robert Schilling
Committed by
Rémy Coutable
Feb 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only require one parameter when updating a Wiki via the API
parent
bd17881b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
17 deletions
+41
-17
changelogs/unreleased/39676-wiki-api-problems-on-update-parameters-and-500-error.yml
...-wiki-api-problems-on-update-parameters-and-500-error.yml
+5
-0
lib/api/wikis.rb
lib/api/wikis.rb
+8
-5
spec/requests/api/wikis_spec.rb
spec/requests/api/wikis_spec.rb
+28
-12
No files found.
changelogs/unreleased/39676-wiki-api-problems-on-update-parameters-and-500-error.yml
0 → 100644
View file @
5b29f066
---
title
:
'
API:
Require
only
one
parameter
when
updating
a
wiki'
merge_request
:
25191
author
:
Robert Schilling
type
:
fixed
lib/api/wikis.rb
View file @
5b29f066
...
...
@@ -11,9 +11,7 @@ module API
}
end
params
:wiki_page_params
do
requires
:content
,
type:
String
,
desc:
'Content of a wiki page'
requires
:title
,
type:
String
,
desc:
'Title of a wiki page'
params
:common_wiki_page_params
do
optional
:format
,
type:
String
,
values:
ProjectWiki
::
MARKUPS
.
values
.
map
(
&
:to_s
),
...
...
@@ -54,7 +52,9 @@ module API
success
Entities
::
WikiPage
end
params
do
use
:wiki_page_params
requires
:title
,
type:
String
,
desc:
'Title of a wiki page'
requires
:content
,
type:
String
,
desc:
'Content of a wiki page'
use
:common_wiki_page_params
end
post
':id/wikis'
do
authorize!
:create_wiki
,
user_project
...
...
@@ -72,7 +72,10 @@ module API
success
Entities
::
WikiPage
end
params
do
use
:wiki_page_params
optional
:title
,
type:
String
,
desc:
'Title of a wiki page'
optional
:content
,
type:
String
,
desc:
'Content of a wiki page'
use
:common_wiki_page_params
at_least_one_of
:content
,
:title
,
:format
end
put
':id/wikis/:slug'
do
authorize!
:create_wiki
,
user_project
...
...
spec/requests/api/wikis_spec.rb
View file @
5b29f066
...
...
@@ -100,6 +100,8 @@ describe API::Wikis do
shared_examples_for
'updates wiki page'
do
it
'updates the wiki page'
do
put
(
api
(
url
,
user
),
params:
payload
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
.
size
).
to
eq
(
4
)
expect
(
json_response
.
keys
).
to
match_array
(
expected_keys_with_content
)
...
...
@@ -107,6 +109,16 @@ describe API::Wikis do
expect
(
json_response
[
'slug'
]).
to
eq
(
payload
[
:title
].
tr
(
' '
,
'-'
))
expect
(
json_response
[
'title'
]).
to
eq
(
payload
[
:title
])
end
[
:title
,
:content
,
:format
].
each
do
|
part
|
it
"it updates with wiki with missing
#{
part
}
"
do
payload
.
delete
(
part
)
put
(
api
(
url
,
user
),
params:
payload
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
end
shared_examples_for
'403 Forbidden'
do
...
...
@@ -528,8 +540,6 @@ describe API::Wikis do
context
'when user is developer'
do
before
do
project
.
add_developer
(
user
)
put
(
api
(
url
,
user
),
params:
payload
)
end
include_examples
'updates wiki page'
...
...
@@ -537,6 +547,10 @@ describe API::Wikis do
context
'when page is not existing'
do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/wikis/unknown"
}
before
do
put
(
api
(
url
,
user
),
params:
payload
)
end
include_examples
'404 Wiki Page Not Found'
end
end
...
...
@@ -544,8 +558,6 @@ describe API::Wikis do
context
'when user is maintainer'
do
before
do
project
.
add_maintainer
(
user
)
put
(
api
(
url
,
user
),
params:
payload
)
end
include_examples
'updates wiki page'
...
...
@@ -553,6 +565,10 @@ describe API::Wikis do
context
'when page is not existing'
do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/wikis/unknown"
}
before
do
put
(
api
(
url
,
user
),
params:
payload
)
end
include_examples
'404 Wiki Page Not Found'
end
end
...
...
@@ -572,8 +588,6 @@ describe API::Wikis do
context
'when user is developer'
do
before
do
project
.
add_developer
(
user
)
put
(
api
(
url
,
user
),
params:
payload
)
end
include_examples
'updates wiki page'
...
...
@@ -581,6 +595,10 @@ describe API::Wikis do
context
'when page is not existing'
do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/wikis/unknown"
}
before
do
put
(
api
(
url
,
user
),
params:
payload
)
end
include_examples
'404 Wiki Page Not Found'
end
end
...
...
@@ -588,8 +606,6 @@ describe API::Wikis do
context
'when user is maintainer'
do
before
do
project
.
add_maintainer
(
user
)
put
(
api
(
url
,
user
),
params:
payload
)
end
include_examples
'updates wiki page'
...
...
@@ -597,6 +613,10 @@ describe API::Wikis do
context
'when page is not existing'
do
let
(
:url
)
{
"/projects/
#{
project
.
id
}
/wikis/unknown"
}
before
do
put
(
api
(
url
,
user
),
params:
payload
)
end
include_examples
'404 Wiki Page Not Found'
end
end
...
...
@@ -605,10 +625,6 @@ describe API::Wikis do
context
'when wiki belongs to a group project'
do
let
(
:project
)
{
create
(
:project
,
:wiki_repo
,
namespace:
group
)
}
before
do
put
(
api
(
url
,
user
),
params:
payload
)
end
include_examples
'updates wiki page'
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