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
a4608a8d
Commit
a4608a8d
authored
Mar 27, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests.
parent
61e8ca8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
121 additions
and
0 deletions
+121
-0
spec/controllers/namespaces_controller_spec.rb
spec/controllers/namespaces_controller_spec.rb
+121
-0
No files found.
spec/controllers/namespaces_controller_spec.rb
0 → 100644
View file @
a4608a8d
require
'spec_helper'
describe
NamespacesController
do
let!
(
:user
)
{
create
(
:user
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
))
}
describe
"GET show"
do
context
"when the namespace belongs to a user"
do
let!
(
:other_user
)
{
create
(
:user
)
}
it
"redirects to the user's page"
do
get
:show
,
id:
other_user
.
username
expect
(
response
).
to
redirect_to
(
user_path
(
other_user
))
end
end
context
"when the namespace belongs to a group"
do
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
context
"when the group has public projects"
do
before
do
project
.
update_attribute
(
:visibility_level
,
Project
::
PUBLIC
)
end
context
"when not signed in"
do
it
"redirects to the group's page"
do
get
:show
,
id:
group
.
path
expect
(
response
).
to
redirect_to
(
group_path
(
group
))
end
end
context
"when signed in"
do
before
do
sign_in
(
user
)
end
it
"redirects to the group's page"
do
get
:show
,
id:
group
.
path
expect
(
response
).
to
redirect_to
(
group_path
(
group
))
end
end
end
context
"when the project doesn't have public projects"
do
context
"when not signed in"
do
it
"redirects to the sign in page"
do
get
:show
,
id:
group
.
path
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
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
it
"redirects to the sign in page"
do
get
:show
,
id:
group
.
path
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
end
end
context
"when the user isn't blocked"
do
it
"redirects to the group's page"
do
get
:show
,
id:
group
.
path
expect
(
response
).
to
redirect_to
(
group_path
(
group
))
end
end
end
context
"when the user doesn't have access to the project"
do
it
"responds with status 404"
do
get
:show
,
id:
group
.
path
expect
(
response
.
status
).
to
eq
(
404
)
end
end
end
end
end
context
"when the namespace doesn't exist"
do
context
"when signed in"
do
before
do
sign_in
(
user
)
end
it
"responds with status 404"
do
get
:show
,
id:
"doesntexist"
expect
(
response
.
status
).
to
eq
(
404
)
end
end
context
"when not signed in"
do
it
"redirects to the sign in page"
do
get
:show
,
id:
"doesntexist"
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
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