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
5cd9c7c6
Commit
5cd9c7c6
authored
Feb 21, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable Rails/Validation
parent
8df3eb66
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
19 additions
and
33 deletions
+19
-33
.rubocop.yml
.rubocop.yml
+3
-0
.rubocop_todo.yml
.rubocop_todo.yml
+0
-17
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+3
-3
app/models/ci/runner_project.rb
app/models/ci/runner_project.rb
+1
-1
app/models/ci/trigger.rb
app/models/ci/trigger.rb
+2
-2
app/models/commit_status.rb
app/models/commit_status.rb
+1
-1
app/models/members/group_member.rb
app/models/members/group_member.rb
+1
-1
app/models/members/project_member.rb
app/models/members/project_member.rb
+1
-1
app/models/pages_domain.rb
app/models/pages_domain.rb
+1
-1
app/models/project.rb
app/models/project.rb
+2
-2
app/models/protected_branch.rb
app/models/protected_branch.rb
+2
-2
app/models/user.rb
app/models/user.rb
+1
-1
No files found.
.rubocop.yml
View file @
5cd9c7c6
...
...
@@ -941,6 +941,9 @@ Rails/OutputSafety:
Rails/TimeZone
:
Enabled
:
false
Rails/Validation
:
Enabled
:
true
Style/AlignParameters
:
Enabled
:
false
...
...
.rubocop_todo.yml
View file @
5cd9c7c6
...
...
@@ -38,23 +38,6 @@ RSpec/SingleArgumentMessageChain:
Exclude
:
-
'
spec/requests/api/internal_spec.rb'
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/Validation
:
Exclude
:
-
'
app/models/ci/build.rb'
-
'
app/models/ci/pipeline.rb'
-
'
app/models/ci/runner_project.rb'
-
'
app/models/ci/trigger.rb'
-
'
app/models/commit_status.rb'
-
'
app/models/members/group_member.rb'
-
'
app/models/members/project_member.rb'
-
'
app/models/pages_domain.rb'
-
'
app/models/project.rb'
-
'
app/models/protected_branch.rb'
-
'
app/models/user.rb'
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
...
...
app/models/ci/build.rb
View file @
5cd9c7c6
...
...
@@ -23,7 +23,7 @@ module Ci
serialize
:yaml_variables
,
Gitlab
::
Serializer
::
Ci
::
Variables
validates
:coverage
,
numericality:
true
,
allow_blank:
true
validates
_presence_of
:ref
validates
:ref
,
presence:
true
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
...
...
app/models/ci/pipeline.rb
View file @
5cd9c7c6
...
...
@@ -14,9 +14,9 @@ module Ci
has_many
:builds
,
foreign_key: :commit_id
has_many
:trigger_requests
,
dependent: :destroy
,
foreign_key: :commit_id
validates
_presence_of
:sha
,
unless: :importing?
validates
_presence_of
:ref
,
unless: :importing?
validates
_presence_of
:status
,
unless: :importing?
validates
:sha
,
presence:
{
unless: :importing?
}
validates
:ref
,
presence:
{
unless: :importing?
}
validates
:status
,
presence:
{
unless: :importing?
}
validate
:valid_commit_sha
,
unless: :importing?
after_create
:keep_around_commits
,
unless: :importing?
...
...
app/models/ci/runner_project.rb
View file @
5cd9c7c6
...
...
@@ -5,6 +5,6 @@ module Ci
belongs_to
:runner
belongs_to
:project
,
foreign_key: :gl_project_id
validates
_uniqueness_of
:runner_id
,
scope: :gl_project_id
validates
:runner_id
,
uniqueness:
{
scope: :gl_project_id
}
end
end
app/models/ci/trigger.rb
View file @
5cd9c7c6
...
...
@@ -7,8 +7,8 @@ module Ci
belongs_to
:project
,
foreign_key: :gl_project_id
has_many
:trigger_requests
,
dependent: :destroy
validates
_presence_of
:token
validates
_uniqueness_of
:token
validates
:token
,
presence:
true
validates
:token
,
uniqueness:
true
before_validation
:set_default_values
...
...
app/models/commit_status.rb
View file @
5cd9c7c6
...
...
@@ -13,7 +13,7 @@ class CommitStatus < ActiveRecord::Base
validates
:pipeline
,
presence:
true
,
unless: :importing?
validates
_presence_of
:nam
e
validates
:name
,
presence:
tru
e
alias_attribute
:author
,
:user
...
...
app/models/members/group_member.rb
View file @
5cd9c7c6
...
...
@@ -5,7 +5,7 @@ class GroupMember < Member
# Make sure group member points only to group as it source
default_value_for
:source_type
,
SOURCE_TYPE
validates
_format_of
:source_type
,
with:
/\ANamespace\z/
validates
:source_type
,
format:
{
with:
/\ANamespace\z/
}
default_scope
{
where
(
source_type:
SOURCE_TYPE
)
}
def
self
.
access_level_roles
...
...
app/models/members/project_member.rb
View file @
5cd9c7c6
...
...
@@ -7,7 +7,7 @@ class ProjectMember < Member
# Make sure project member points only to project as it source
default_value_for
:source_type
,
SOURCE_TYPE
validates
_format_of
:source_type
,
with:
/\AProject\z/
validates
:source_type
,
format:
{
with:
/\AProject\z/
}
validates
:access_level
,
inclusion:
{
in:
Gitlab
::
Access
.
values
}
default_scope
{
where
(
source_type:
SOURCE_TYPE
)
}
...
...
app/models/pages_domain.rb
View file @
5cd9c7c6
...
...
@@ -2,7 +2,7 @@ class PagesDomain < ActiveRecord::Base
belongs_to
:project
validates
:domain
,
hostname:
true
validates
_uniqueness_of
:domain
,
case_sensitive:
false
validates
:domain
,
uniqueness:
{
case_sensitive:
false
}
validates
:certificate
,
certificate:
true
,
allow_nil:
true
,
allow_blank:
true
validates
:key
,
certificate_key:
true
,
allow_nil:
true
,
allow_blank:
true
...
...
app/models/project.rb
View file @
5cd9c7c6
...
...
@@ -191,8 +191,8 @@ class Project < ActiveRecord::Base
format:
{
with:
Gitlab
::
Regex
.
project_path_regex
,
message:
Gitlab
::
Regex
.
project_path_regex_message
}
validates
:namespace
,
presence:
true
validates
_uniqueness_of
:name
,
scope: :namespace_id
validates
_uniqueness_of
:path
,
scope: :namespace_id
validates
:name
,
uniqueness:
{
scope: :namespace_id
}
validates
:path
,
uniqueness:
{
scope: :namespace_id
}
validates
:import_url
,
addressable_url:
true
,
if: :external_import?
validates
:star_count
,
numericality:
{
greater_than_or_equal_to:
0
}
validate
:check_limit
,
on: :create
...
...
app/models/protected_branch.rb
View file @
5cd9c7c6
...
...
@@ -8,8 +8,8 @@ class ProtectedBranch < ActiveRecord::Base
has_many
:merge_access_levels
,
dependent: :destroy
has_many
:push_access_levels
,
dependent: :destroy
validates
_length_of
:merge_access_levels
,
is:
1
,
message:
"are restricted to a single instance per protected branch."
validates
_length_of
:push_access_levels
,
is:
1
,
message:
"are restricted to a single instance per protected branch."
validates
:merge_access_levels
,
length:
{
is:
1
,
message:
"are restricted to a single instance per protected branch."
}
validates
:push_access_levels
,
length:
{
is:
1
,
message:
"are restricted to a single instance per protected branch."
}
accepts_nested_attributes_for
:push_access_levels
accepts_nested_attributes_for
:merge_access_levels
...
...
app/models/user.rb
View file @
5cd9c7c6
...
...
@@ -104,7 +104,7 @@ class User < ActiveRecord::Base
#
# Note: devise :validatable above adds validations for :email and :password
validates
:name
,
presence:
true
validates
_confirmation_of
:email
validates
:email
,
confirmation:
true
validates
:notification_email
,
presence:
true
validates
:notification_email
,
email:
true
,
if:
->
(
user
)
{
user
.
notification_email
!=
user
.
email
}
validates
:public_email
,
presence:
true
,
uniqueness:
true
,
email:
true
,
allow_blank:
true
...
...
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