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
b5540112
Commit
b5540112
authored
May 14, 2019
by
Peter Marko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix project visibility level validation
parent
deccdd72
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
app/models/project.rb
app/models/project.rb
+6
-2
changelogs/unreleased/fix-project-visibility-level-validation.yml
...gs/unreleased/fix-project-visibility-level-validation.yml
+5
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+7
-0
No files found.
app/models/project.rb
View file @
b5540112
...
@@ -336,8 +336,8 @@ class Project < ApplicationRecord
...
@@ -336,8 +336,8 @@ class Project < ApplicationRecord
validates
:star_count
,
numericality:
{
greater_than_or_equal_to:
0
}
validates
:star_count
,
numericality:
{
greater_than_or_equal_to:
0
}
validate
:check_personal_projects_limit
,
on: :create
validate
:check_personal_projects_limit
,
on: :create
validate
:check_repository_path_availability
,
on: :update
,
if:
->
(
project
)
{
project
.
renamed?
}
validate
:check_repository_path_availability
,
on: :update
,
if:
->
(
project
)
{
project
.
renamed?
}
validate
:visibility_level_allowed_by_group
,
if:
->
{
changes
.
has_key?
(
:visibility_level
)
}
validate
:visibility_level_allowed_by_group
,
if:
:should_validate_visibility_level?
validate
:visibility_level_allowed_as_fork
,
if:
->
{
changes
.
has_key?
(
:visibility_level
)
}
validate
:visibility_level_allowed_as_fork
,
if:
:should_validate_visibility_level?
validate
:check_wiki_path_conflict
validate
:check_wiki_path_conflict
validate
:validate_pages_https_only
,
if:
->
{
changes
.
has_key?
(
:pages_https_only
)
}
validate
:validate_pages_https_only
,
if:
->
{
changes
.
has_key?
(
:pages_https_only
)
}
validates
:repository_storage
,
validates
:repository_storage
,
...
@@ -891,6 +891,10 @@ class Project < ApplicationRecord
...
@@ -891,6 +891,10 @@ class Project < ApplicationRecord
self
.
errors
.
add
(
:limit_reached
,
error
%
{
limit:
limit
})
self
.
errors
.
add
(
:limit_reached
,
error
%
{
limit:
limit
})
end
end
def
should_validate_visibility_level?
new_record?
||
changes
.
has_key?
(
:visibility_level
)
end
def
visibility_level_allowed_by_group
def
visibility_level_allowed_by_group
return
if
visibility_level_allowed_by_group?
return
if
visibility_level_allowed_by_group?
...
...
changelogs/unreleased/fix-project-visibility-level-validation.yml
0 → 100644
View file @
b5540112
---
title
:
Fix project visibility level validation
merge_request
:
28305
author
:
Peter Marko
type
:
fixed
spec/models/project_spec.rb
View file @
b5540112
...
@@ -214,6 +214,13 @@ describe Project do
...
@@ -214,6 +214,13 @@ describe Project do
expect
(
project2
).
not_to
be_valid
expect
(
project2
).
not_to
be_valid
end
end
it
'validates the visibility'
do
expect_any_instance_of
(
described_class
).
to
receive
(
:visibility_level_allowed_as_fork
).
and_call_original
expect_any_instance_of
(
described_class
).
to
receive
(
:visibility_level_allowed_by_group
).
and_call_original
create
(
:project
)
end
describe
'wiki path conflict'
do
describe
'wiki path conflict'
do
context
"when the new path has been used by the wiki of other Project"
do
context
"when the new path has been used by the wiki of other Project"
do
it
'has an error on the name attribute'
do
it
'has an error on the name attribute'
do
...
...
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