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
Boxiang Sun
gitlab-ce
Commits
45e8650c
Commit
45e8650c
authored
Mar 20, 2016
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs
parent
19aa20d5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
22 deletions
+13
-22
app/models/project.rb
app/models/project.rb
+2
-2
app/services/groups/base_service.rb
app/services/groups/base_service.rb
+1
-1
lib/gitlab/visibility_level.rb
lib/gitlab/visibility_level.rb
+0
-4
spec/helpers/projects_helper_spec.rb
spec/helpers/projects_helper_spec.rb
+1
-9
spec/models/group_spec.rb
spec/models/group_spec.rb
+2
-2
spec/services/groups/update_service_spec.rb
spec/services/groups/update_service_spec.rb
+7
-4
No files found.
app/models/project.rb
View file @
45e8650c
...
@@ -198,7 +198,7 @@ class Project < ActiveRecord::Base
...
@@ -198,7 +198,7 @@ class Project < ActiveRecord::Base
if:
->
(
project
)
{
project
.
avatar
.
present?
&&
project
.
avatar_changed?
}
if:
->
(
project
)
{
project
.
avatar
.
present?
&&
project
.
avatar_changed?
}
validates
:avatar
,
file_size:
{
maximum:
200
.
kilobytes
.
to_i
}
validates
:avatar
,
file_size:
{
maximum:
200
.
kilobytes
.
to_i
}
validate
:visibility_level_allowed_by_group
validate
:visibility_level_allowed_by_group
validate
:visibility_level_allowed_as_fork
validate
:visibility_level_allowed_as_fork
,
on: :update
add_authentication_token_field
:runners_token
add_authentication_token_field
:runners_token
before_save
:ensure_runners_token
before_save
:ensure_runners_token
...
@@ -974,7 +974,7 @@ class Project < ActiveRecord::Base
...
@@ -974,7 +974,7 @@ class Project < ActiveRecord::Base
def
visibility_level_allowed_as_fork?
(
level
=
self
.
visibility_level
)
def
visibility_level_allowed_as_fork?
(
level
=
self
.
visibility_level
)
return
true
unless
forked?
return
true
unless
forked?
Gitlab
::
VisibilityLevel
.
allowed_fork_levels
(
forked_from_project
.
visibility_level
).
include?
(
level
)
level
<=
forked_from_project
.
visibility_level
end
end
def
visibility_level_allowed_by_group?
(
level
=
self
.
visibility_level
)
def
visibility_level_allowed_by_group?
(
level
=
self
.
visibility_level
)
...
...
app/services/groups/base_service.rb
View file @
45e8650c
module
Groups
module
Groups
class
BaseService
<
BaseService
class
BaseService
<
::
BaseService
attr_accessor
:group
,
:current_user
,
:params
attr_accessor
:group
,
:current_user
,
:params
def
initialize
(
group
,
user
,
params
=
{})
def
initialize
(
group
,
user
,
params
=
{})
...
...
lib/gitlab/visibility_level.rb
View file @
45e8650c
...
@@ -56,10 +56,6 @@ module Gitlab
...
@@ -56,10 +56,6 @@ module Gitlab
options
.
has_value?
(
level
)
options
.
has_value?
(
level
)
end
end
def
allowed_fork_levels
(
origin_level
)
[
PRIVATE
,
INTERNAL
,
PUBLIC
].
select
{
|
level
|
level
<=
origin_level
}
end
def
level_name
(
level
)
def
level_name
(
level
)
level_name
=
'Unknown'
level_name
=
'Unknown'
options
.
each
do
|
name
,
lvl
|
options
.
each
do
|
name
,
lvl
|
...
...
spec/helpers/projects_helper_spec.rb
View file @
45e8650c
...
@@ -11,16 +11,8 @@ describe ProjectsHelper do
...
@@ -11,16 +11,8 @@ describe ProjectsHelper do
describe
"can_change_visibility_level?"
do
describe
"can_change_visibility_level?"
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:fork_project
)
do
fork_project
=
create
(
:forked_project_with_submodules
)
fork_project
.
build_forked_project_link
(
forked_to_project_id:
fork_project
.
id
,
forked_from_project_id:
project
.
id
)
fork_project
.
save
fork_project
end
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:fork_project
)
{
Projects
::
ForkService
.
new
(
project
,
user
).
execute
}
it
"returns false if there are no appropriate permissions"
do
it
"returns false if there are no appropriate permissions"
do
allow
(
helper
).
to
receive
(
:can?
)
{
false
}
allow
(
helper
).
to
receive
(
:can?
)
{
false
}
...
...
spec/models/group_spec.rb
View file @
45e8650c
...
@@ -67,9 +67,9 @@ describe Group, models: true do
...
@@ -67,9 +67,9 @@ describe Group, models: true do
end
end
describe
'public_and_internal_only'
do
describe
'public_and_internal_only'
do
subject
{
described_class
.
public_and_internal_only
.
to_a
}
subject
{
described_class
.
public_and_internal_only
.
to_a
.
sort
}
it
{
is_expected
.
to
eq
([
group
,
internal_group
])
}
it
{
is_expected
.
to
eq
([
group
,
internal_group
]
.
sort
)
}
end
end
end
end
...
...
spec/services/groups/update_service_spec.rb
View file @
45e8650c
...
@@ -16,8 +16,9 @@ describe Groups::UpdateService, services: true do
...
@@ -16,8 +16,9 @@ describe Groups::UpdateService, services: true do
create
(
:project
,
:public
,
group:
public_group
)
create
(
:project
,
:public
,
group:
public_group
)
end
end
it
"cant downgrade permission level"
do
it
"does not change permission level"
do
expect
(
public_group
.
errors
.
count
).
to
eq
(
2
)
service
.
execute
expect
(
public_group
.
errors
.
count
).
to
eq
(
1
)
end
end
end
end
...
@@ -29,8 +30,9 @@ describe Groups::UpdateService, services: true do
...
@@ -29,8 +30,9 @@ describe Groups::UpdateService, services: true do
create
(
:project
,
:internal
,
group:
internal_group
)
create
(
:project
,
:internal
,
group:
internal_group
)
end
end
it
"cant downgrade permission level"
do
it
"does not change permission level"
do
expect
(
internal_group
.
errors
.
count
).
to
eq
(
2
)
service
.
execute
expect
(
internal_group
.
errors
.
count
).
to
eq
(
1
)
end
end
end
end
end
end
...
@@ -43,6 +45,7 @@ describe Groups::UpdateService, services: true do
...
@@ -43,6 +45,7 @@ describe Groups::UpdateService, services: true do
end
end
it
"does not change permission level"
do
it
"does not change permission level"
do
service
.
execute
expect
(
internal_group
.
errors
.
count
).
to
eq
(
1
)
expect
(
internal_group
.
errors
.
count
).
to
eq
(
1
)
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