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
Léo-Paul Géneau
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
validates
:coverage
,
numericality:
true
,
allow_blank:
true
validates
:ref
,
presence:
true
validates
:protected
,
inclusion:
{
in:
[
true
,
false
]
},
on: :create
scope
:unstarted
,
->
()
{
where
(
runner_id:
nil
)
}
scope
:ignore_failures
,
->
()
{
where
(
allow_failure:
false
)
}
...
...
app/models/ci/pipeline.rb
View file @
ce7c0ac3
...
...
@@ -36,6 +36,7 @@ module Ci
validates
:sha
,
presence:
{
unless: :importing?
}
validates
:ref
,
presence:
{
unless: :importing?
}
validates
:status
,
presence:
{
unless: :importing?
}
validates
:protected
,
inclusion:
{
in:
[
true
,
false
],
unless: :importing?
},
on: :create
validate
:valid_commit_sha
,
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
CLONE_ACCESSORS
=
%i[pipeline project ref tag options commands name
allow_failure stage_id stage stage_idx trigger_request
yaml_variables when environment coverage_regex
description tag_list]
.
freeze
description tag_list
protected
]
.
freeze
def
execute
(
build
)
reprocess!
(
build
).
tap
do
|
new_build
|
...
...
spec/factories/ci/builds.rb
View file @
ce7c0ac3
...
...
@@ -12,6 +12,7 @@ FactoryGirl.define do
started_at
'Di 29. Okt 09:51:28 CET 2013'
finished_at
'Di 29. Okt 09:53:28 CET 2013'
commands
'ls -a'
protected
false
options
do
{
...
...
@@ -227,11 +228,11 @@ FactoryGirl.define do
self
.
when
'manual'
end
trait
(
:protected
)
do
trait
:protected
do
protected
true
end
trait
(
:unprotected
)
do
trait
:unprotected
do
protected
false
end
end
...
...
spec/factories/ci/pipelines.rb
View file @
ce7c0ac3
...
...
@@ -4,6 +4,7 @@ FactoryGirl.define do
ref
'master'
sha
'97de212e80737a608d939f648d959671fb0a0142'
status
'pending'
protected
false
project
...
...
@@ -59,6 +60,14 @@ FactoryGirl.define do
trait
:failed
do
status
:failed
end
trait
:protected
do
protected
true
end
trait
:unprotected
do
protected
false
end
end
end
end
spec/models/ci/build_spec.rb
View file @
ce7c0ac3
...
...
@@ -59,7 +59,11 @@ describe Ci::Build do
end
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
)
}
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