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
c16b9a01
Commit
c16b9a01
authored
Feb 25, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for file size and file type for create and update group avatar
parent
67ecbcf0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+54
-0
No files found.
spec/requests/api/groups_spec.rb
View file @
c16b9a01
...
@@ -583,6 +583,34 @@ describe API::Groups do
...
@@ -583,6 +583,34 @@ describe API::Groups do
"
#{
group1
.
id
}
/banana_sample.gif"
)
"
#{
group1
.
id
}
/banana_sample.gif"
)
end
end
it
'returns 400 if file type is invalid to update avatar'
do
group_param
=
{
avatar:
fixture_file_upload
(
'spec/fixtures/doc_sample.txt'
,
'text/plain'
)
}
put
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
),
params:
group_param
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
response
.
message
).
to
eq
(
'Bad Request'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Failed to save group'
\
' {:avatar=>["file format is not supported.'
\
' Please try one of the following supported formats:'
\
'png, jpg, jpeg, gif, bmp, tiff, ico"]}'
)
end
it
'returns 400 if file size exceeds allowed limit for group avatar'
do
group_param
=
{
avatar:
fixture_file_upload
(
'spec/fixtures/doc_sample.txt'
,
'text/plain'
)
}
put
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
),
params:
group_param
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
response
.
message
).
to
eq
(
'Bad Request'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Failed to save group'
\
' {:avatar=>["is too big (should be at most 200 KB)"]}'
)
end
it
'returns 404 for a non existing group'
do
it
'returns 404 for a non existing group'
do
put
api
(
'/groups/1328'
,
user1
),
params:
{
name:
new_group_name
}
put
api
(
'/groups/1328'
,
user1
),
params:
{
name:
new_group_name
}
...
@@ -1013,6 +1041,32 @@ describe API::Groups do
...
@@ -1013,6 +1041,32 @@ describe API::Groups do
"
#{
group_id
}
/banana_sample.gif"
)
"
#{
group_id
}
/banana_sample.gif"
)
end
end
it
'returns a 400 if file type is invalid for group avatar'
do
group
=
attributes_for_group_api
request_access_enabled:
false
group
[
:avatar
]
=
fixture_file_upload
(
'spec/fixtures/doc_sample.txt'
,
'text/plain'
)
post
api
(
"/groups"
,
user3
),
params:
group
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
response
.
message
).
to
eq
(
'Bad Request'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Failed to save group'
\
' {:avatar=>["file format is not supported.'
\
' Please try one of the following supported formats:'
\
'png, jpg, jpeg, gif, bmp, tiff, ico"]}'
)
end
it
'returns 400 if group avatar file size exceeds allowed limit'
do
group
=
attributes_for_group_api
request_access_enabled:
false
group
[
:avatar
]
=
fixture_file_upload
(
'spec/fixtures/big-image.png'
,
'image/png'
)
post
api
(
"/groups"
,
user3
),
params:
group
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
response
.
message
).
to
eq
(
'Bad Request'
)
expect
(
json_response
[
'message'
]).
to
eq
(
'Failed to save group'
\
' {:avatar=>["is too big (should be at most 200 KB)"]}'
)
end
it
"creates a nested group"
do
it
"creates a nested group"
do
parent
=
create
(
:group
)
parent
=
create
(
:group
)
parent
.
add_owner
(
user3
)
parent
.
add_owner
(
user3
)
...
...
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