BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
8b830b8c
Commit
8b830b8c
authored
Mar 18, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs
parent
b959ae55
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
27 additions
and
16 deletions
+27
-16
project.rb
app/models/project.rb
+8
-2
create_service.rb
app/services/projects/create_service.rb
+4
-1
group.rb
features/steps/shared/group.rb
+2
-2
namespaces_controller_spec.rb
spec/controllers/namespaces_controller_spec.rb
+1
-1
uploads_controller_spec.rb
spec/controllers/uploads_controller_spec.rb
+3
-2
projects_spec.rb
spec/features/projects_spec.rb
+4
-4
group_access_spec.rb
spec/features/security/group_access_spec.rb
+1
-1
projects_finder_spec.rb
spec/finders/projects_finder_spec.rb
+1
-1
snippets_finder_spec.rb
spec/finders/snippets_finder_spec.rb
+1
-1
project_spec.rb
spec/models/project_spec.rb
+1
-1
projects_spec.rb
spec/requests/api/projects_spec.rb
+1
-0
No files found.
app/models/project.rb
View file @
8b830b8c
...
@@ -969,8 +969,9 @@ class Project < ActiveRecord::Base
...
@@ -969,8 +969,9 @@ class Project < ActiveRecord::Base
end
end
def
visibility_level_allowed?
(
level
=
self
.
visibility_level
)
def
visibility_level_allowed?
(
level
=
self
.
visibility_level
)
allowed_by_forks
=
if
forked?
allowed_by_forks
=
if
forked?
&&
forked_project_link
.
forked_from_project_id
.
present?
Gitlab
::
VisibilityLevel
.
allowed_fork_levels
(
forked_from_project
.
visibility_level
).
include?
(
level
)
from_project
=
eager_load_forked_from_project
Gitlab
::
VisibilityLevel
.
allowed_fork_levels
(
from_project
.
visibility_level
).
include?
(
level
)
else
else
true
true
end
end
...
@@ -980,6 +981,11 @@ class Project < ActiveRecord::Base
...
@@ -980,6 +981,11 @@ class Project < ActiveRecord::Base
allowed_by_forks
&&
allowed_by_groups
allowed_by_forks
&&
allowed_by_groups
end
end
#Necessary to retrieve many-to-many associations on new forks before validating visibility level
def
eager_load_forked_from_project
Project
.
find
(
forked_project_link
.
forked_from_project_id
)
end
def
runners_token
def
runners_token
ensure_runners_token!
ensure_runners_token!
end
end
...
...
app/services/projects/create_service.rb
View file @
8b830b8c
...
@@ -10,7 +10,10 @@ module Projects
...
@@ -10,7 +10,10 @@ module Projects
@project
=
Project
.
new
(
params
)
@project
=
Project
.
new
(
params
)
# Make sure that the user is allowed to use the specified visibility level
# Make sure that the user is allowed to use the specified visibility level
return
@project
unless
visibility_level_allowed?
unless
visibility_level_allowed?
deny_visibility_level
(
@project
)
return
@project
end
# Set project name from path
# Set project name from path
if
@project
.
name
.
present?
&&
@project
.
path
.
present?
if
@project
.
name
.
present?
&&
@project
.
path
.
present?
...
...
features/steps/shared/group.rb
View file @
8b830b8c
...
@@ -38,7 +38,7 @@ module SharedGroup
...
@@ -38,7 +38,7 @@ module SharedGroup
def
is_member_of
(
username
,
groupname
,
role
)
def
is_member_of
(
username
,
groupname
,
role
)
@project_count
||=
0
@project_count
||=
0
user
=
User
.
find_by
(
name:
username
)
||
create
(
:user
,
name:
username
)
user
=
User
.
find_by
(
name:
username
)
||
create
(
:user
,
name:
username
)
group
=
Group
.
find_by
(
name:
groupname
)
||
create
(
:group
,
name:
groupname
)
group
=
Group
.
find_by
(
name:
groupname
)
||
create
(
:group
,
name:
groupname
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
group
.
add_user
(
user
,
role
)
group
.
add_user
(
user
,
role
)
project
||=
create
(
:project
,
namespace:
group
,
path:
"project
#{
@project_count
}
"
)
project
||=
create
(
:project
,
namespace:
group
,
path:
"project
#{
@project_count
}
"
)
create
(
:closed_issue_event
,
project:
project
)
create
(
:closed_issue_event
,
project:
project
)
...
@@ -47,6 +47,6 @@ module SharedGroup
...
@@ -47,6 +47,6 @@ module SharedGroup
end
end
def
owned_group
def
owned_group
@owned_group
||=
Group
.
find_by
(
name:
"Owned"
)
@owned_group
||=
Group
.
find_by
(
name:
"Owned"
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
end
end
end
end
spec/controllers/namespaces_controller_spec.rb
View file @
8b830b8c
...
@@ -15,7 +15,7 @@ describe NamespacesController do
...
@@ -15,7 +15,7 @@ describe NamespacesController do
end
end
context
"when the namespace belongs to a group"
do
context
"when the namespace belongs to a group"
do
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:group
)
{
create
(
:group
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
context
"when the group has public projects"
do
context
"when the group has public projects"
do
...
...
spec/controllers/uploads_controller_spec.rb
View file @
8b830b8c
...
@@ -30,7 +30,7 @@ describe UploadsController do
...
@@ -30,7 +30,7 @@ describe UploadsController do
end
end
end
end
end
end
context
"when not signed in"
do
context
"when not signed in"
do
it
"responds with status 200"
do
it
"responds with status 200"
do
get
:show
,
model:
"user"
,
mounted_as:
"avatar"
,
id:
user
.
id
,
filename:
"image.png"
get
:show
,
model:
"user"
,
mounted_as:
"avatar"
,
id:
user
.
id
,
filename:
"image.png"
...
@@ -126,11 +126,12 @@ describe UploadsController do
...
@@ -126,11 +126,12 @@ describe UploadsController do
end
end
context
"when viewing a group avatar"
do
context
"when viewing a group avatar"
do
let!
(
:group
)
{
create
(
:group
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
))
}
let!
(
:group
)
{
create
(
:group
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
))
}
let!
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
context
"when the group has public projects"
do
context
"when the group has public projects"
do
before
do
before
do
group
.
update_attribute
(
:visibility_level
,
Gitlab
::
VisibilityLevel
::
PUBLIC
)
project
.
update_attribute
(
:visibility_level
,
Project
::
PUBLIC
)
project
.
update_attribute
(
:visibility_level
,
Project
::
PUBLIC
)
end
end
...
...
spec/features/projects_spec.rb
View file @
8b830b8c
...
@@ -12,25 +12,25 @@ feature 'Project', feature: true do
...
@@ -12,25 +12,25 @@ feature 'Project', feature: true do
it
'parses Markdown'
do
it
'parses Markdown'
do
project
.
update_attribute
(
:description
,
'This is **my** project'
)
project
.
update_attribute
(
:description
,
'This is **my** project'
)
visit
path
visit
path
expect
(
page
).
to
have_css
(
'.
project-home-desc
> p > strong'
)
expect
(
page
).
to
have_css
(
'.
cover-title
> p > strong'
)
end
end
it
'passes through html-pipeline'
do
it
'passes through html-pipeline'
do
project
.
update_attribute
(
:description
,
'This project is the :poop:'
)
project
.
update_attribute
(
:description
,
'This project is the :poop:'
)
visit
path
visit
path
expect
(
page
).
to
have_css
(
'.
project-home-desc
> p > img'
)
expect
(
page
).
to
have_css
(
'.
cover-title
> p > img'
)
end
end
it
'sanitizes unwanted tags'
do
it
'sanitizes unwanted tags'
do
project
.
update_attribute
(
:description
,
"```
\n
code
\n
```"
)
project
.
update_attribute
(
:description
,
"```
\n
code
\n
```"
)
visit
path
visit
path
expect
(
page
).
not_to
have_css
(
'.
project-home-desc
code'
)
expect
(
page
).
not_to
have_css
(
'.
cover-title
code'
)
end
end
it
'permits `rel` attribute on links'
do
it
'permits `rel` attribute on links'
do
project
.
update_attribute
(
:description
,
'https://google.com/'
)
project
.
update_attribute
(
:description
,
'https://google.com/'
)
visit
path
visit
path
expect
(
page
).
to
have_css
(
'.
project-home-desc
a[rel]'
)
expect
(
page
).
to
have_css
(
'.
cover-title
a[rel]'
)
end
end
end
end
...
...
spec/features/security/group_access_spec.rb
View file @
8b830b8c
...
@@ -4,7 +4,7 @@ describe 'Group access', feature: true do
...
@@ -4,7 +4,7 @@ describe 'Group access', feature: true do
include
AccessMatchers
include
AccessMatchers
def
group
def
group
@group
||=
create
(
:group
)
@group
||=
create
(
:group
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
end
end
def
create_project
(
access_level
)
def
create_project
(
access_level
)
...
...
spec/finders/projects_finder_spec.rb
View file @
8b830b8c
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
ProjectsFinder
do
describe
ProjectsFinder
do
describe
'#execute'
do
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:group
)
{
create
(
:group
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
}
let!
(
:private_project
)
do
let!
(
:private_project
)
do
create
(
:project
,
:private
,
name:
'A'
,
path:
'A'
)
create
(
:project
,
:private
,
name:
'A'
,
path:
'A'
)
...
...
spec/finders/snippets_finder_spec.rb
View file @
8b830b8c
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
SnippetsFinder
do
describe
SnippetsFinder
do
let
(
:user
)
{
create
:user
}
let
(
:user
)
{
create
:user
}
let
(
:user1
)
{
create
:user
}
let
(
:user1
)
{
create
:user
}
let
(
:group
)
{
create
:group
}
let
(
:group
)
{
create
:group
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
}
let
(
:project1
)
{
create
(
:empty_project
,
:public
,
group:
group
)
}
let
(
:project1
)
{
create
(
:empty_project
,
:public
,
group:
group
)
}
let
(
:project2
)
{
create
(
:empty_project
,
:private
,
group:
group
)
}
let
(
:project2
)
{
create
(
:empty_project
,
:private
,
group:
group
)
}
...
...
spec/models/project_spec.rb
View file @
8b830b8c
...
@@ -442,7 +442,7 @@ describe Project, models: true do
...
@@ -442,7 +442,7 @@ describe Project, models: true do
end
end
describe
'.trending'
do
describe
'.trending'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
(
:project1
)
{
create
(
:empty_project
,
:public
,
group:
group
)
}
let
(
:project1
)
{
create
(
:empty_project
,
:public
,
group:
group
)
}
let
(
:project2
)
{
create
(
:empty_project
,
:public
,
group:
group
)
}
let
(
:project2
)
{
create
(
:empty_project
,
:public
,
group:
group
)
}
...
...
spec/requests/api/projects_spec.rb
View file @
8b830b8c
...
@@ -275,6 +275,7 @@ describe API::API, api: true do
...
@@ -275,6 +275,7 @@ describe API::API, api: true do
it
'should not allow a non-admin to use a restricted visibility level'
do
it
'should not allow a non-admin to use a restricted visibility level'
do
post
api
(
'/projects'
,
user
),
@project
post
api
(
'/projects'
,
user
),
@project
expect
(
response
.
status
).
to
eq
(
400
)
expect
(
response
.
status
).
to
eq
(
400
)
expect
(
json_response
[
'message'
][
'visibility_level'
].
first
).
to
(
expect
(
json_response
[
'message'
][
'visibility_level'
].
first
).
to
(
match
(
'restricted by your GitLab administrator'
)
match
(
'restricted by your GitLab administrator'
)
...
...
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