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
bd3388f3
Commit
bd3388f3
authored
Feb 29, 2020
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add all avatar upload specs under one shared examples
parent
420e5547
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
40 deletions
+22
-40
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+22
-40
No files found.
spec/requests/api/groups_spec.rb
View file @
bd3388f3
...
...
@@ -22,7 +22,7 @@ describe API::Groups do
end
shared_examples
'group avatar upload'
do
context
'when valid
file is used
'
do
context
'when valid'
do
let
(
:file_path
)
{
'spec/fixtures/banana_sample.gif'
}
it
'returns avatar url in response'
do
...
...
@@ -34,16 +34,30 @@ describe API::Groups do
"
#{
group_id
}
/banana_sample.gif"
)
end
end
end
shared_examples
'invalid file upload request'
do
context
'when invalid'
do
it
'returns 400'
do
make_upload_request
shared_examples
'invalid file upload request'
do
it
'returns 400'
do
make_upload_request
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
response
.
message
).
to
eq
(
'Bad Request'
)
expect
(
json_response
[
'message'
].
to_s
).
to
match
(
/
#{
message
}
/
)
expect
(
response
).
to
have_gitlab_http_status
(
:bad_request
)
expect
(
response
.
message
).
to
eq
(
'Bad Request'
)
expect
(
json_response
[
'message'
].
to_s
).
to
match
(
/
#{
message
}
/
)
end
end
context
'when file format is not supported'
do
let
(
:file_path
)
{
'spec/fixtures/doc_sample.txt'
}
let
(
:message
)
{
'file format is not supported. Please try one of the following supported formats: png, jpg, jpeg, gif, bmp, tiff, ico'
}
it_behaves_like
'invalid file upload request'
end
context
'when file format is not supported'
do
let
(
:file_path
)
{
'spec/fixtures/big-image.png'
}
let
(
:message
)
{
'is too big'
}
it_behaves_like
'invalid file upload request'
end
end
end
...
...
@@ -575,22 +589,6 @@ describe API::Groups do
it_behaves_like
'group avatar upload'
context
'group avatar update'
do
context
'when file format is not supported'
do
let
(
:file_path
)
{
'spec/fixtures/doc_sample.txt'
}
let
(
:message
)
{
'file format is not supported. Please try one of the following supported formats: png, jpg, jpeg, gif, bmp, tiff, ico'
}
it_behaves_like
'invalid file upload request'
end
context
'when file size is large'
do
let
(
:file_path
)
{
'spec/fixtures/big-image.png'
}
let
(
:message
)
{
"is too big"
}
it_behaves_like
'invalid file upload request'
end
end
context
'when authenticated as the group owner'
do
it
'updates the group'
do
put
api
(
"/groups/
#{
group1
.
id
}
"
,
user1
),
params:
{
...
...
@@ -1000,22 +998,6 @@ describe API::Groups do
it_behaves_like
'group avatar upload'
context
'group avatar upload'
do
context
'when file format is not supported'
do
let
(
:file_path
)
{
'spec/fixtures/doc_sample.txt'
}
let
(
:message
)
{
'file format is not supported. Please try one of the following supported formats: png, jpg, jpeg, gif, bmp, tiff, ico'
}
it_behaves_like
'invalid file upload request'
end
context
'when file size is large'
do
let
(
:file_path
)
{
'spec/fixtures/big-image.png'
}
let
(
:message
)
{
"is too big"
}
it_behaves_like
'invalid file upload request'
end
end
context
"when authenticated as user without group permissions"
do
it
"does not create group"
do
group
=
attributes_for_group_api
...
...
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