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
Jérome Perrin
gitlab-ce
Commits
805715cc
Commit
805715cc
authored
May 30, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add stage seed class that represents attributes
parent
325b2d93
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
2 deletions
+86
-2
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+1
-2
lib/gitlab/ci/stage/seed.rb
lib/gitlab/ci/stage/seed.rb
+38
-0
spec/lib/gitlab/ci/stage/seed_spec.rb
spec/lib/gitlab/ci/stage/seed_spec.rb
+47
-0
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
805715cc
...
...
@@ -81,8 +81,7 @@ module Ci
dependencies:
job
[
:dependencies
],
after_script:
job
[
:after_script
],
environment:
job
[
:environment
]
}.
compact
}
}.
compact
}
end
def
self
.
validation_message
(
content
)
...
...
lib/gitlab/ci/stage/seed.rb
0 → 100644
View file @
805715cc
module
Gitlab
module
Ci
module
Stage
class
Seed
attr_reader
:name
,
:builds
def
initialize
(
name
:,
builds
:)
@name
=
name
@builds
=
builds
end
def
pipeline
=
(
pipeline
)
trigger_request
=
pipeline
.
trigger_requests
.
first
@builds
.
each
do
|
attributes
|
attributes
.
merge!
(
pipeline:
pipeline
,
project:
pipeline
.
project
,
ref:
pipeline
.
ref
,
tag:
pipeline
.
tag
,
trigger_request:
trigger_request
)
end
end
def
user
=
(
current_user
)
@builds
.
each
do
|
attributes
|
attributes
.
merge!
(
user:
current_user
)
end
end
def
to_attributes
{
name:
@name
,
builds_attributes:
@builds
}
end
end
end
end
end
spec/lib/gitlab/ci/stage/seed_spec.rb
0 → 100644
View file @
805715cc
require
'spec_helper'
describe
Gitlab
::
Ci
::
Stage
::
Seed
do
subject
do
described_class
.
new
(
name:
'test'
,
builds:
builds
)
end
let
(
:builds
)
do
[{
name:
'rspec'
},
{
name:
'spinach'
}]
end
describe
'#pipeline='
do
let
(
:pipeline
)
do
create
(
:ci_empty_pipeline
,
ref:
'feature'
,
tag:
true
)
end
it
'assignes relevant pipeline attributes'
do
trigger_request
=
pipeline
.
trigger_requests
.
first
subject
.
pipeline
=
pipeline
expect
(
subject
.
builds
).
to
all
(
include
(
pipeline:
pipeline
))
expect
(
subject
.
builds
).
to
all
(
include
(
project:
pipeline
.
project
))
expect
(
subject
.
builds
).
to
all
(
include
(
ref:
'feature'
))
expect
(
subject
.
builds
).
to
all
(
include
(
tag:
true
))
expect
(
subject
.
builds
).
to
all
(
include
(
trigger_request:
trigger_request
))
end
end
describe
'#user='
do
let
(
:user
)
{
create
(
:user
)
}
it
'assignes relevant pipeline attributes'
do
subject
.
user
=
user
expect
(
subject
.
builds
).
to
all
(
include
(
user:
user
))
end
end
describe
'#to_attributes'
do
it
'exposes stage attributes with nested jobs'
do
expect
(
subject
.
to_attributes
).
to
be_a
Hash
expect
(
subject
.
to_attributes
).
to
include
(
name:
'test'
)
expect
(
subject
.
to_attributes
).
to
include
(
builds_attributes:
builds
)
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