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
iv
gitlab-ce
Commits
1615d3de
Commit
1615d3de
authored
Apr 17, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests.
parent
305725f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
223 additions
and
0 deletions
+223
-0
spec/controllers/projects/uploads_controller_spec.rb
spec/controllers/projects/uploads_controller_spec.rb
+223
-0
No files found.
spec/controllers/projects/uploads_controller_spec.rb
View file @
1615d3de
...
@@ -54,4 +54,227 @@ describe Projects::UploadsController do
...
@@ -54,4 +54,227 @@ describe Projects::UploadsController do
end
end
end
end
end
end
describe
"GET #show"
do
let
(
:go
)
do
get
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
secret:
"123456"
,
filename:
"image.jpg"
end
context
"when the project is public"
do
before
do
project
.
update_attribute
(
:visibility_level
,
Project
::
PUBLIC
)
end
context
"when not signed in"
do
context
"when the file exists"
do
before
do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:file
).
and_return
(
jpg
)
allow
(
jpg
).
to
receive
(
:exists?
).
and_return
(
true
)
end
it
"responds with status 200"
do
go
expect
(
response
.
status
).
to
eq
(
200
)
end
end
context
"when the file doesn't exist"
do
it
"responds with status 404"
do
go
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
context
"when signed in"
do
before
do
sign_in
(
user
)
end
context
"when the file exists"
do
before
do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:file
).
and_return
(
jpg
)
allow
(
jpg
).
to
receive
(
:exists?
).
and_return
(
true
)
end
it
"responds with status 200"
do
go
expect
(
response
.
status
).
to
eq
(
200
)
end
end
context
"when the file doesn't exist"
do
it
"responds with status 404"
do
go
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
end
context
"when the project is private"
do
before
do
project
.
update_attribute
(
:visibility_level
,
Project
::
PRIVATE
)
end
context
"when not signed in"
do
context
"when the file exists"
do
before
do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:file
).
and_return
(
jpg
)
allow
(
jpg
).
to
receive
(
:exists?
).
and_return
(
true
)
end
context
"when the file is an image"
do
before
do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:image?
).
and_return
(
true
)
end
it
"responds with status 200"
do
go
expect
(
response
.
status
).
to
eq
(
200
)
end
end
context
"when the file is not an image"
do
it
"redirects to the sign in page"
do
go
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
end
end
end
context
"when the file doesn't exist"
do
it
"redirects to the sign in page"
do
go
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
end
end
end
context
"when signed in"
do
before
do
sign_in
(
user
)
end
context
"when the user has access to the project"
do
before
do
project
.
team
<<
[
user
,
:master
]
end
context
"when the user is blocked"
do
before
do
user
.
block
project
.
team
<<
[
user
,
:master
]
end
context
"when the file exists"
do
before
do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:file
).
and_return
(
jpg
)
allow
(
jpg
).
to
receive
(
:exists?
).
and_return
(
true
)
end
context
"when the file is an image"
do
before
do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:image?
).
and_return
(
true
)
end
it
"responds with status 200"
do
go
expect
(
response
.
status
).
to
eq
(
200
)
end
end
context
"when the file is not an image"
do
it
"redirects to the sign in page"
do
go
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
end
end
end
context
"when the file doesn't exist"
do
it
"redirects to the sign in page"
do
go
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
end
end
end
context
"when the user isn't blocked"
do
context
"when the file exists"
do
before
do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:file
).
and_return
(
jpg
)
allow
(
jpg
).
to
receive
(
:exists?
).
and_return
(
true
)
end
it
"responds with status 200"
do
go
expect
(
response
.
status
).
to
eq
(
200
)
end
end
context
"when the file doesn't exist"
do
it
"responds with status 404"
do
go
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
end
context
"when the user doesn't have access to the project"
do
context
"when the file exists"
do
before
do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:file
).
and_return
(
jpg
)
allow
(
jpg
).
to
receive
(
:exists?
).
and_return
(
true
)
end
context
"when the file is an image"
do
before
do
allow_any_instance_of
(
FileUploader
).
to
receive
(
:image?
).
and_return
(
true
)
end
it
"responds with status 200"
do
go
expect
(
response
.
status
).
to
eq
(
200
)
end
end
context
"when the file is not an image"
do
it
"responds with status 404"
do
go
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
context
"when the file doesn't exist"
do
it
"responds with status 404"
do
go
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
end
end
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