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
ce7c0ac3
Commit
ce7c0ac3
authored
Aug 31, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add validation for protected attributes
parent
f3d3cecf
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
4 deletions
+20
-4
app/models/ci/build.rb
app/models/ci/build.rb
+1
-0
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+1
-0
app/services/ci/retry_build_service.rb
app/services/ci/retry_build_service.rb
+1
-1
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+3
-2
spec/factories/ci/pipelines.rb
spec/factories/ci/pipelines.rb
+9
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+5
-1
No files found.
app/models/ci/build.rb
View file @
ce7c0ac3
...
@@ -26,6 +26,7 @@ module Ci
...
@@ -26,6 +26,7 @@ module Ci
validates
:coverage
,
numericality:
true
,
allow_blank:
true
validates
:coverage
,
numericality:
true
,
allow_blank:
true
validates
:ref
,
presence:
true
validates
:ref
,
presence:
true
validates
:protected
,
inclusion:
{
in:
[
true
,
false
]
},
on: :create
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
...
...
app/models/ci/pipeline.rb
View file @
ce7c0ac3
...
@@ -36,6 +36,7 @@ module Ci
...
@@ -36,6 +36,7 @@ module Ci
validates
:sha
,
presence:
{
unless: :importing?
}
validates
:sha
,
presence:
{
unless: :importing?
}
validates
:ref
,
presence:
{
unless: :importing?
}
validates
:ref
,
presence:
{
unless: :importing?
}
validates
:status
,
presence:
{
unless: :importing?
}
validates
:status
,
presence:
{
unless: :importing?
}
validates
:protected
,
inclusion:
{
in:
[
true
,
false
],
unless: :importing?
},
on: :create
validate
:valid_commit_sha
,
unless: :importing?
validate
:valid_commit_sha
,
unless: :importing?
after_create
:keep_around_commits
,
unless: :importing?
after_create
:keep_around_commits
,
unless: :importing?
...
...
app/services/ci/retry_build_service.rb
View file @
ce7c0ac3
...
@@ -3,7 +3,7 @@ module Ci
...
@@ -3,7 +3,7 @@ module Ci
CLONE_ACCESSORS
=
%i[pipeline project ref tag options commands name
CLONE_ACCESSORS
=
%i[pipeline project ref tag options commands name
allow_failure stage_id stage stage_idx trigger_request
allow_failure stage_id stage stage_idx trigger_request
yaml_variables when environment coverage_regex
yaml_variables when environment coverage_regex
description tag_list]
.
freeze
description tag_list
protected
]
.
freeze
def
execute
(
build
)
def
execute
(
build
)
reprocess!
(
build
).
tap
do
|
new_build
|
reprocess!
(
build
).
tap
do
|
new_build
|
...
...
spec/factories/ci/builds.rb
View file @
ce7c0ac3
...
@@ -12,6 +12,7 @@ FactoryGirl.define do
...
@@ -12,6 +12,7 @@ FactoryGirl.define do
started_at
'Di 29. Okt 09:51:28 CET 2013'
started_at
'Di 29. Okt 09:51:28 CET 2013'
finished_at
'Di 29. Okt 09:53:28 CET 2013'
finished_at
'Di 29. Okt 09:53:28 CET 2013'
commands
'ls -a'
commands
'ls -a'
protected
false
options
do
options
do
{
{
...
@@ -227,11 +228,11 @@ FactoryGirl.define do
...
@@ -227,11 +228,11 @@ FactoryGirl.define do
self
.
when
'manual'
self
.
when
'manual'
end
end
trait
(
:protected
)
do
trait
:protected
do
protected
true
protected
true
end
end
trait
(
:unprotected
)
do
trait
:unprotected
do
protected
false
protected
false
end
end
end
end
...
...
spec/factories/ci/pipelines.rb
View file @
ce7c0ac3
...
@@ -4,6 +4,7 @@ FactoryGirl.define do
...
@@ -4,6 +4,7 @@ FactoryGirl.define do
ref
'master'
ref
'master'
sha
'97de212e80737a608d939f648d959671fb0a0142'
sha
'97de212e80737a608d939f648d959671fb0a0142'
status
'pending'
status
'pending'
protected
false
project
project
...
@@ -59,6 +60,14 @@ FactoryGirl.define do
...
@@ -59,6 +60,14 @@ FactoryGirl.define do
trait
:failed
do
trait
:failed
do
status
:failed
status
:failed
end
end
trait
:protected
do
protected
true
end
trait
:unprotected
do
protected
false
end
end
end
end
end
end
end
spec/models/ci/build_spec.rb
View file @
ce7c0ac3
...
@@ -59,7 +59,11 @@ describe Ci::Build do
...
@@ -59,7 +59,11 @@ describe Ci::Build do
end
end
context
'when protected is false'
do
context
'when protected is false'
do
let!
(
:job
)
{
create
(
:ci_build
,
protected:
nil
)
}
let!
(
:job
)
{
create
(
:ci_build
)
}
before
do
job
.
update_attribute
(
:protected
,
nil
)
end
it
{
is_expected
.
not_to
include
(
job
)
}
it
{
is_expected
.
not_to
include
(
job
)
}
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