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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
af7214d0
Commit
af7214d0
authored
Apr 11, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs
parent
5d69f5b4
Changes
28
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
106 additions
and
194 deletions
+106
-194
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+6
-2
app/helpers/ci_status_helper.rb
app/helpers/ci_status_helper.rb
+2
-0
app/models/ci/commit.rb
app/models/ci/commit.rb
+21
-6
app/models/commit_status.rb
app/models/commit_status.rb
+2
-7
app/models/concerns/ci_status.rb
app/models/concerns/ci_status.rb
+2
-1
app/services/ci/create_builds_service.rb
app/services/ci/create_builds_service.rb
+1
-1
app/services/ci/create_trigger_request_service.rb
app/services/ci/create_trigger_request_service.rb
+2
-2
app/services/ci/image_for_build_service.rb
app/services/ci/image_for_build_service.rb
+6
-5
app/services/create_commit_builds_service.rb
app/services/create_commit_builds_service.rb
+1
-0
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+1
-1
app/views/shared/projects/_project.html.haml
app/views/shared/projects/_project.html.haml
+2
-2
db/fixtures/development/14_builds.rb
db/fixtures/development/14_builds.rb
+1
-1
features/steps/project/merge_requests.rb
features/steps/project/merge_requests.rb
+1
-1
features/steps/shared/project.rb
features/steps/shared/project.rb
+1
-1
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+10
-4
spec/features/commits_spec.rb
spec/features/commits_spec.rb
+5
-0
spec/helpers/ci_status_helper_spec.rb
spec/helpers/ci_status_helper_spec.rb
+2
-2
spec/lib/gitlab/badge/build_spec.rb
spec/lib/gitlab/badge/build_spec.rb
+3
-3
spec/models/ci/commit_spec.rb
spec/models/ci/commit_spec.rb
+6
-111
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+1
-15
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+2
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-2
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+1
-1
spec/requests/api/commit_status_spec.rb
spec/requests/api/commit_status_spec.rb
+10
-9
spec/requests/api/commits_spec.rb
spec/requests/api/commits_spec.rb
+2
-2
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+10
-10
spec/services/ci/create_builds_service_spec.rb
spec/services/ci/create_builds_service_spec.rb
+2
-2
spec/services/ci/image_for_build_service_spec.rb
spec/services/ci/image_for_build_service_spec.rb
+1
-1
No files found.
app/controllers/projects/commit_controller.rb
View file @
af7214d0
...
@@ -38,13 +38,13 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -38,13 +38,13 @@ class Projects::CommitController < Projects::ApplicationController
end
end
def
cancel_builds
def
cancel_builds
ci_
commit
.
builds
.
running_or_pending
.
each
(
&
:cancel
)
ci_builds
.
running_or_pending
.
each
(
&
:cancel
)
redirect_back_or_default
default:
builds_namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
.
sha
)
redirect_back_or_default
default:
builds_namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
.
sha
)
end
end
def
retry_builds
def
retry_builds
ci_
commit
.
builds
.
latest
.
failed
.
each
do
|
build
|
ci_builds
.
latest
.
failed
.
each
do
|
build
|
if
build
.
retryable?
if
build
.
retryable?
Ci
::
Build
.
retry
(
build
)
Ci
::
Build
.
retry
(
build
)
end
end
...
@@ -98,6 +98,10 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -98,6 +98,10 @@ class Projects::CommitController < Projects::ApplicationController
@ci_commits
||=
project
.
ci_commits
.
where
(
sha:
commit
.
sha
)
@ci_commits
||=
project
.
ci_commits
.
where
(
sha:
commit
.
sha
)
end
end
def
ci_builds
@ci_builds
||=
Ci
::
Build
.
where
(
commit:
ci_commits
)
end
def
define_show_vars
def
define_show_vars
return
git_not_found!
unless
commit
return
git_not_found!
unless
commit
...
...
app/helpers/ci_status_helper.rb
View file @
af7214d0
...
@@ -34,6 +34,8 @@ module CiStatusHelper
...
@@ -34,6 +34,8 @@ module CiStatusHelper
end
end
def
render_ci_status
(
ci_commit
,
tooltip_placement:
'auto left'
)
def
render_ci_status
(
ci_commit
,
tooltip_placement:
'auto left'
)
return
unless
ci_commit
.
is_a?
(
Commit
)
||
ci_commit
.
is_a?
(
Ci
::
Commit
)
link_to
ci_icon_for_status
(
ci_commit
.
status
),
link_to
ci_icon_for_status
(
ci_commit
.
status
),
project_ci_commit_path
(
ci_commit
.
project
,
ci_commit
),
project_ci_commit_path
(
ci_commit
.
project
,
ci_commit
),
class:
"ci-status-link ci-status-icon-
#{
ci_commit
.
status
.
dasherize
}
"
,
class:
"ci-status-link ci-status-icon-
#{
ci_commit
.
status
.
dasherize
}
"
,
...
...
app/models/ci/commit.rb
View file @
af7214d0
...
@@ -35,6 +35,11 @@ module Ci
...
@@ -35,6 +35,11 @@ module Ci
before_save
:finished_at
before_save
:finished_at
before_save
:duration
before_save
:duration
# Invalidate object and save if when touched
after_touch
:reload
after_touch
:invalidate
after_touch
:save
def
self
.
truncate_sha
(
sha
)
def
self
.
truncate_sha
(
sha
)
sha
[
0
...
8
]
sha
[
0
...
8
]
end
end
...
@@ -86,9 +91,10 @@ module Ci
...
@@ -86,9 +91,10 @@ module Ci
end
end
def
invalidate
def
invalidate
status
=
nil
write_attribute
(
:status
,
nil
)
started_at
=
nil
write_attribute
(
:started_at
,
nil
)
finished_at
=
nil
write_attribute
(
:finished_at
,
nil
)
write_attribute
(
:duration
,
nil
)
end
end
def
create_builds
(
user
,
trigger_request
=
nil
)
def
create_builds
(
user
,
trigger_request
=
nil
)
...
@@ -183,18 +189,18 @@ module Ci
...
@@ -183,18 +189,18 @@ module Ci
if
yaml_errors
.
present?
if
yaml_errors
.
present?
'failed'
'failed'
else
else
latest
.
status
latest
.
status
||
'skipped'
end
end
end
end
def
update_started_at
def
update_started_at
started_at
=
started_at
=
statuses
.
order
(
:id
).
first
.
try
(
:started_at
)
statuses
.
minimum
(
:started_at
)
end
end
def
update_finished_at
def
update_finished_at
finished_at
=
finished_at
=
statuses
.
order
(
id: :desc
).
first
.
try
(
:finished_at
)
statuses
.
maximum
(
:finished_at
)
end
end
def
update_duration
def
update_duration
...
@@ -204,9 +210,18 @@ module Ci
...
@@ -204,9 +210,18 @@ module Ci
end
end
end
end
def
update_statuses
update_status
update_started_at
update_finished_at
update_duration
save
end
def
save_yaml_error
(
error
)
def
save_yaml_error
(
error
)
return
if
self
.
yaml_errors?
return
if
self
.
yaml_errors?
self
.
yaml_errors
=
error
self
.
yaml_errors
=
error
update_status
save
save
end
end
end
end
...
...
app/models/commit_status.rb
View file @
af7214d0
...
@@ -38,7 +38,7 @@ class CommitStatus < ActiveRecord::Base
...
@@ -38,7 +38,7 @@ class CommitStatus < ActiveRecord::Base
self
.
table_name
=
'ci_builds'
self
.
table_name
=
'ci_builds'
belongs_to
:project
,
class_name:
'::Project'
,
foreign_key: :gl_project_id
belongs_to
:project
,
class_name:
'::Project'
,
foreign_key: :gl_project_id
belongs_to
:commit
,
class_name:
'Ci::Commit'
belongs_to
:commit
,
class_name:
'Ci::Commit'
,
touch:
true
belongs_to
:user
belongs_to
:user
validates
:commit
,
presence:
true
validates
:commit
,
presence:
true
...
@@ -47,7 +47,7 @@ class CommitStatus < ActiveRecord::Base
...
@@ -47,7 +47,7 @@ class CommitStatus < ActiveRecord::Base
alias_attribute
:author
,
:user
alias_attribute
:author
,
:user
scope
:latest
,
->
{
where
(
id:
unscope
(
:select
).
select
(
'max(id)'
).
group
(
:name
))
}
scope
:latest
,
->
{
where
(
id:
unscope
(
:select
).
select
(
'max(id)'
).
group
(
:name
,
:commit_id
))
}
scope
:ordered
,
->
{
order
(
:ref
,
:stage_idx
,
:name
)
}
scope
:ordered
,
->
{
order
(
:ref
,
:stage_idx
,
:name
)
}
AVAILABLE_STATUSES
=
[
'pending'
,
'running'
,
'success'
,
'failed'
,
'canceled'
]
AVAILABLE_STATUSES
=
[
'pending'
,
'running'
,
'success'
,
'failed'
,
'canceled'
]
...
@@ -80,11 +80,6 @@ class CommitStatus < ActiveRecord::Base
...
@@ -80,11 +80,6 @@ class CommitStatus < ActiveRecord::Base
after_transition
[
:pending
,
:running
]
=>
:success
do
|
commit_status
|
after_transition
[
:pending
,
:running
]
=>
:success
do
|
commit_status
|
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
commit_status
.
commit
.
project
,
nil
).
trigger
(
commit_status
)
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
commit_status
.
commit
.
project
,
nil
).
trigger
(
commit_status
)
end
end
after_transition
any
=>
any
do
|
commit_status
|
commit_status
.
commit
.
invalidate
commit_status
.
save
end
end
end
delegate
:before_sha
,
:sha
,
:short_sha
,
to: :commit
,
prefix:
false
delegate
:before_sha
,
:sha
,
:short_sha
,
to: :commit
,
prefix:
false
...
...
app/models/concerns/ci_status.rb
View file @
af7214d0
...
@@ -26,7 +26,7 @@ module CiStatus
...
@@ -26,7 +26,7 @@ module CiStatus
end
end
included
do
included
do
validates
:status
,
inclusion:
{
in:
%w(pending running failed success canceled)
}
validates
:status
,
inclusion:
{
in:
%w(pending running failed success canceled
skipped
)
}
state_machine
:status
,
initial: :pending
do
state_machine
:status
,
initial: :pending
do
state
:pending
,
value:
'pending'
state
:pending
,
value:
'pending'
...
@@ -34,6 +34,7 @@ module CiStatus
...
@@ -34,6 +34,7 @@ module CiStatus
state
:failed
,
value:
'failed'
state
:failed
,
value:
'failed'
state
:success
,
value:
'success'
state
:success
,
value:
'success'
state
:canceled
,
value:
'canceled'
state
:canceled
,
value:
'canceled'
state
:skipped
,
value:
'skipped'
end
end
scope
:running
,
->
{
where
(
status:
'running'
)
}
scope
:running
,
->
{
where
(
status:
'running'
)
}
...
...
app/services/ci/create_builds_service.rb
View file @
af7214d0
...
@@ -21,7 +21,7 @@ module Ci
...
@@ -21,7 +21,7 @@ module Ci
builds_attrs
.
map
do
|
build_attrs
|
builds_attrs
.
map
do
|
build_attrs
|
# don't create the same build twice
# don't create the same build twice
unless
commit
.
builds
.
find_by
(
ref:
@commit
.
ref
,
tag:
@commit
.
tag
,
unless
@
commit
.
builds
.
find_by
(
ref:
@commit
.
ref
,
tag:
@commit
.
tag
,
trigger_request:
trigger_request
,
name:
build_attrs
[
:name
])
trigger_request:
trigger_request
,
name:
build_attrs
[
:name
])
build_attrs
.
slice!
(
:name
,
build_attrs
.
slice!
(
:name
,
:commands
,
:commands
,
...
...
app/services/ci/create_trigger_request_service.rb
View file @
af7214d0
...
@@ -7,14 +7,14 @@ module Ci
...
@@ -7,14 +7,14 @@ module Ci
# check if ref is tag
# check if ref is tag
tag
=
project
.
repository
.
find_tag
(
ref
).
present?
tag
=
project
.
repository
.
find_tag
(
ref
).
present?
ci_commit
=
project
.
ci_commits
.
create
(
commit
.
sha
,
ref
)
ci_commit
=
project
.
ci_commits
.
create
(
sha:
commit
.
sha
,
ref:
ref
,
tag:
tag
)
trigger_request
=
trigger
.
trigger_requests
.
create!
(
trigger_request
=
trigger
.
trigger_requests
.
create!
(
variables:
variables
,
variables:
variables
,
commit:
ci_commit
,
commit:
ci_commit
,
)
)
if
ci_commit
.
create_builds
(
ref
,
tag
,
nil
,
trigger_request
)
if
ci_commit
.
create_builds
(
nil
,
trigger_request
)
trigger_request
trigger_request
end
end
end
end
...
...
app/services/ci/image_for_build_service.rb
View file @
af7214d0
...
@@ -3,8 +3,9 @@ module Ci
...
@@ -3,8 +3,9 @@ module Ci
def
execute
(
project
,
opts
)
def
execute
(
project
,
opts
)
sha
=
opts
[
:sha
]
||
ref_sha
(
project
,
opts
[
:ref
])
sha
=
opts
[
:sha
]
||
ref_sha
(
project
,
opts
[
:ref
])
commit
=
project
.
ci_commits
.
find_by
(
sha:
sha
)
ci_commits
=
project
.
ci_commits
.
where
(
sha:
sha
)
image_name
=
image_for_commit
(
commit
)
ci_commits
=
ci_commits
.
where
(
ref:
opts
[
:ref
])
if
opts
[
:ref
]
image_name
=
image_for_status
(
ci_commits
.
status
)
image_path
=
Rails
.
root
.
join
(
'public/ci'
,
image_name
)
image_path
=
Rails
.
root
.
join
(
'public/ci'
,
image_name
)
OpenStruct
.
new
(
path:
image_path
,
name:
image_name
)
OpenStruct
.
new
(
path:
image_path
,
name:
image_name
)
...
@@ -16,9 +17,9 @@ module Ci
...
@@ -16,9 +17,9 @@ module Ci
project
.
commit
(
ref
).
try
(
:sha
)
if
ref
project
.
commit
(
ref
).
try
(
:sha
)
if
ref
end
end
def
image_for_
commit
(
commit
)
def
image_for_
status
(
status
)
return
'build-unknown.svg'
unless
commit
status
||=
'unknown'
'build-'
+
commit
.
status
+
".svg"
'build-'
+
status
+
".svg"
end
end
end
end
end
end
app/services/create_commit_builds_service.rb
View file @
af7214d0
...
@@ -37,6 +37,7 @@ class CreateCommitBuildsService
...
@@ -37,6 +37,7 @@ class CreateCommitBuildsService
commit
.
create_builds
(
user
)
commit
.
create_builds
(
user
)
end
end
commit
.
touch
commit
commit
end
end
end
end
app/views/projects/builds/show.html.haml
View file @
af7214d0
...
@@ -196,7 +196,7 @@
...
@@ -196,7 +196,7 @@
.build-widget
.build-widget
%h4
.title
#{
pluralize
(
@builds
.
count
(
:id
),
"other build"
)
}
for
%h4
.title
#{
pluralize
(
@builds
.
count
(
:id
),
"other build"
)
}
for
=
succeed
":"
do
=
succeed
":"
do
=
link_to
@build
.
commit
.
short_sha
,
builds_namespace_project_commit_path
(
@project
.
namespace
,
@project
,
build
.
sha
),
class:
"monospace"
=
link_to
@build
.
commit
.
short_sha
,
builds_namespace_project_commit_path
(
@project
.
namespace
,
@project
,
@
build
.
sha
),
class:
"monospace"
%table
.table.builds
%table
.table.builds
-
@builds
.
each_with_index
do
|
build
,
i
|
-
@builds
.
each_with_index
do
|
build
,
i
|
%tr
.build
%tr
.build
...
...
app/views/shared/projects/_project.html.haml
View file @
af7214d0
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
-
show_last_commit_as_description
=
false
unless
local_assigns
[
:show_last_commit_as_description
]
==
true
&&
project
.
commit
-
show_last_commit_as_description
=
false
unless
local_assigns
[
:show_last_commit_as_description
]
==
true
&&
project
.
commit
-
css_class
+=
" no-description"
if
project
.
description
.
blank?
&&
!
show_last_commit_as_description
-
css_class
+=
" no-description"
if
project
.
description
.
blank?
&&
!
show_last_commit_as_description
-
cache_key
=
[
project
.
namespace
,
project
,
controller
.
controller_name
,
controller
.
action_name
,
current_application_settings
,
'v2.3'
]
-
cache_key
=
[
project
.
namespace
,
project
,
controller
.
controller_name
,
controller
.
action_name
,
current_application_settings
,
'v2.3'
]
-
cache_key
.
push
(
project
.
commit
.
status
)
if
project
.
commit
.
status
-
cache_key
.
push
(
project
.
commit
.
status
)
if
project
.
commit
.
try
(
:status
)
%li
.project-row
{
class:
css_class
}
%li
.project-row
{
class:
css_class
}
=
cache
(
cache_key
)
do
=
cache
(
cache_key
)
do
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
-
if
project
.
main_language
-
if
project
.
main_language
%span
%span
=
project
.
main_language
=
project
.
main_language
-
if
project
.
commit
.
status
-
if
project
.
commit
.
try
(
:status
)
%span
%span
=
render_ci_status
(
project
.
commit
)
=
render_ci_status
(
project
.
commit
)
-
if
forks
-
if
forks
...
...
db/fixtures/development/14_builds.rb
View file @
af7214d0
...
@@ -19,7 +19,7 @@ class Gitlab::Seeder::Builds
...
@@ -19,7 +19,7 @@ class Gitlab::Seeder::Builds
commits
=
@project
.
repository
.
commits
(
'master'
,
nil
,
5
)
commits
=
@project
.
repository
.
commits
(
'master'
,
nil
,
5
)
commits_sha
=
commits
.
map
{
|
commit
|
commit
.
raw
.
id
}
commits_sha
=
commits
.
map
{
|
commit
|
commit
.
raw
.
id
}
commits_sha
.
map
do
|
sha
|
commits_sha
.
map
do
|
sha
|
@project
.
ensure_ci_commit
(
sha
)
@project
.
ensure_ci_commit
(
sha
,
'master'
)
end
end
rescue
rescue
[]
[]
...
...
features/steps/project/merge_requests.rb
View file @
af7214d0
...
@@ -515,7 +515,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
...
@@ -515,7 +515,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step
'"Bug NS-05" has CI status'
do
step
'"Bug NS-05" has CI status'
do
project
=
merge_request
.
source_project
project
=
merge_request
.
source_project
project
.
enable_ci
project
.
enable_ci
ci_commit
=
create
:ci_commit
,
project:
project
,
sha:
merge_request
.
last_commit
.
id
ci_commit
=
create
:ci_commit
,
project:
project
,
sha:
merge_request
.
last_commit
.
id
,
ref:
merge_request
.
source_branch
create
:ci_build
,
commit:
ci_commit
create
:ci_build
,
commit:
ci_commit
end
end
...
...
features/steps/shared/project.rb
View file @
af7214d0
...
@@ -230,7 +230,7 @@ module SharedProject
...
@@ -230,7 +230,7 @@ module SharedProject
step
'project "Shop" has CI build'
do
step
'project "Shop" has CI build'
do
project
=
Project
.
find_by
(
name:
"Shop"
)
project
=
Project
.
find_by
(
name:
"Shop"
)
create
:ci_commit
,
project:
project
,
sha:
project
.
commit
.
sha
create
:ci_commit
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
'master'
end
end
step
'I should see last commit with CI status'
do
step
'I should see last commit with CI status'
do
...
...
lib/api/commit_statuses.rb
View file @
af7214d0
...
@@ -21,10 +21,9 @@ module API
...
@@ -21,10 +21,9 @@ module API
authorize!
(
:read_commit_status
,
user_project
)
authorize!
(
:read_commit_status
,
user_project
)
not_found!
(
'Commit'
)
unless
user_project
.
commit
(
params
[
:sha
])
not_found!
(
'Commit'
)
unless
user_project
.
commit
(
params
[
:sha
])
ci_commit
=
user_project
.
ci_commit
(
params
[
:sha
],
params
[
:ref
])
return
[]
unless
ci_commit
statuses
=
ci_commit
.
statuses
ci_commits
=
user_project
.
ci_commits
.
where
(
sha:
params
[
:sha
])
statuses
=
::
CommitStatus
.
where
(
commit:
ci_commits
)
statuses
=
statuses
.
latest
unless
parse_boolean
(
params
[
:all
])
statuses
=
statuses
.
latest
unless
parse_boolean
(
params
[
:all
])
statuses
=
statuses
.
where
(
ref:
params
[
:ref
])
if
params
[
:ref
].
present?
statuses
=
statuses
.
where
(
ref:
params
[
:ref
])
if
params
[
:ref
].
present?
statuses
=
statuses
.
where
(
stage:
params
[
:stage
])
if
params
[
:stage
].
present?
statuses
=
statuses
.
where
(
stage:
params
[
:stage
])
if
params
[
:stage
].
present?
...
@@ -51,7 +50,14 @@ module API
...
@@ -51,7 +50,14 @@ module API
commit
=
@project
.
commit
(
params
[
:sha
])
commit
=
@project
.
commit
(
params
[
:sha
])
not_found!
'Commit'
unless
commit
not_found!
'Commit'
unless
commit
ci_commit
=
@project
.
ensure_ci_commit
(
commit
.
sha
)
ref
=
params
[
:ref
]
||
begin
branches
=
@project
.
repository
.
branch_names_contains
(
commit
.
sha
)
not_found!
'Reference for commit'
if
branches
.
none?
branches
.
first
end
ci_commit
=
@project
.
ensure_ci_commit
(
commit
.
sha
,
ref
)
name
=
params
[
:name
]
||
params
[
:context
]
name
=
params
[
:name
]
||
params
[
:context
]
status
=
GenericCommitStatus
.
running_or_pending
.
find_by
(
commit:
ci_commit
,
name:
name
,
ref:
params
[
:ref
])
status
=
GenericCommitStatus
.
running_or_pending
.
find_by
(
commit:
ci_commit
,
name:
name
,
ref:
params
[
:ref
])
...
...
spec/features/commits_spec.rb
View file @
af7214d0
...
@@ -162,4 +162,9 @@ describe 'Commits' do
...
@@ -162,4 +162,9 @@ describe 'Commits' do
end
end
end
end
end
end
def
ci_status_path
(
ci_commit
)
project
=
ci_commit
.
project
builds_namespace_project_commit_path
(
project
.
namespace
,
project
,
ci_commit
.
sha
)
end
end
end
spec/helpers/ci_status_helper_spec.rb
View file @
af7214d0
...
@@ -7,7 +7,7 @@ describe CiStatusHelper do
...
@@ -7,7 +7,7 @@ describe CiStatusHelper do
let
(
:failed_commit
)
{
double
(
"Ci::Commit"
,
status:
'failed'
)
}
let
(
:failed_commit
)
{
double
(
"Ci::Commit"
,
status:
'failed'
)
}
describe
'ci_status_icon'
do
describe
'ci_status_icon'
do
it
{
expect
(
helper
.
ci_
status_icon
(
success_commit
)).
to
include
(
'fa-check'
)
}
it
{
expect
(
helper
.
ci_
icon_for_status
(
success_commit
.
status
)).
to
include
(
'fa-check'
)
}
it
{
expect
(
helper
.
ci_
status_icon
(
failed_commit
)).
to
include
(
'fa-close'
)
}
it
{
expect
(
helper
.
ci_
icon_for_status
(
failed_commit
.
status
)).
to
include
(
'fa-close'
)
}
end
end
end
end
spec/lib/gitlab/badge/build_spec.rb
View file @
af7214d0
...
@@ -42,7 +42,7 @@ describe Gitlab::Badge::Build do
...
@@ -42,7 +42,7 @@ describe Gitlab::Badge::Build do
end
end
context
'build exists'
do
context
'build exists'
do
let
(
:ci_commit
)
{
create
(
:ci_commit
,
project:
project
,
sha:
sha
)
}
let
(
:ci_commit
)
{
create
(
:ci_commit
,
project:
project
,
sha:
sha
,
ref:
branch
)
}
let!
(
:build
)
{
create
(
:ci_build
,
commit:
ci_commit
)
}
let!
(
:build
)
{
create
(
:ci_build
,
commit:
ci_commit
)
}
...
@@ -57,7 +57,7 @@ describe Gitlab::Badge::Build do
...
@@ -57,7 +57,7 @@ describe Gitlab::Badge::Build do
describe
'#data'
do
describe
'#data'
do
let
(
:data
)
{
badge
.
data
}
let
(
:data
)
{
badge
.
data
}
it
'contains inf
ro
mation about success'
do
it
'contains inf
or
mation about success'
do
expect
(
status_node
(
data
,
'success'
)).
to
be_truthy
expect
(
status_node
(
data
,
'success'
)).
to
be_truthy
end
end
end
end
...
@@ -74,7 +74,7 @@ describe Gitlab::Badge::Build do
...
@@ -74,7 +74,7 @@ describe Gitlab::Badge::Build do
describe
'#data'
do
describe
'#data'
do
let
(
:data
)
{
badge
.
data
}
let
(
:data
)
{
badge
.
data
}
it
'contains inf
ro
mation about failure'
do
it
'contains inf
or
mation about failure'
do
expect
(
status_node
(
data
,
'failed'
)).
to
be_truthy
expect
(
status_node
(
data
,
'failed'
)).
to
be_truthy
end
end
end
end
...
...
spec/models/ci/commit_spec.rb
View file @
af7214d0
...
@@ -52,57 +52,9 @@ describe Ci::Commit, models: true do
...
@@ -52,57 +52,9 @@ describe Ci::Commit, models: true do
it
{
expect
(
commit
.
sha
).
to
start_with
(
subject
)
}
it
{
expect
(
commit
.
sha
).
to
start_with
(
subject
)
}
end
end
describe
:stage
do
subject
{
commit
.
stage
}
before
do
@second
=
FactoryGirl
.
create
:commit_status
,
commit:
commit
,
name:
'deploy'
,
stage:
'deploy'
,
stage_idx:
1
,
status:
'pending'
@first
=
FactoryGirl
.
create
:commit_status
,
commit:
commit
,
name:
'test'
,
stage:
'test'
,
stage_idx:
0
,
status:
'pending'
end
it
'returns first running stage'
do
is_expected
.
to
eq
(
'test'
)
end
context
'first build succeeded'
do
before
do
@first
.
success
end
it
'returns last running stage'
do
is_expected
.
to
eq
(
'deploy'
)
end
end
context
'all builds succeeded'
do
before
do
@first
.
success
@second
.
success
end
it
'returns nil'
do
is_expected
.
to
be_nil
end
end
end
describe
:create_next_builds
do
describe
:create_next_builds
do
end
end
describe
:refs
do
subject
{
commit
.
refs
}
before
do
FactoryGirl
.
create
:commit_status
,
commit:
commit
,
name:
'deploy'
FactoryGirl
.
create
:commit_status
,
commit:
commit
,
name:
'deploy'
,
ref:
'develop'
FactoryGirl
.
create
:commit_status
,
commit:
commit
,
name:
'deploy'
,
ref:
'master'
end
it
'returns all refs'
do
is_expected
.
to
contain_exactly
(
'master'
,
'develop'
,
nil
)
end
end
describe
:retried
do
describe
:retried
do
subject
{
commit
.
retried
}
subject
{
commit
.
retried
}
...
@@ -117,10 +69,10 @@ describe Ci::Commit, models: true do
...
@@ -117,10 +69,10 @@ describe Ci::Commit, models: true do
end
end
describe
:create_builds
do
describe
:create_builds
do
let!
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
}
let!
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
,
ref:
'master'
,
tag:
false
}
def
create_builds
(
trigger_request
=
nil
)
def
create_builds
(
trigger_request
=
nil
)
commit
.
create_builds
(
'master'
,
false
,
nil
,
trigger_request
)
commit
.
create_builds
(
nil
,
trigger_request
)
end
end
def
create_next_builds
def
create_next_builds
...
@@ -143,67 +95,6 @@ describe Ci::Commit, models: true do
...
@@ -143,67 +95,6 @@ describe Ci::Commit, models: true do
expect
(
create_next_builds
).
to
be_falsey
expect
(
create_next_builds
).
to
be_falsey
end
end
context
'for different ref'
do
def
create_develop_builds
commit
.
create_builds
(
'develop'
,
false
,
nil
,
nil
)
end
it
'creates builds'
do
expect
(
create_builds
).
to
be_truthy
commit
.
builds
.
update_all
(
status:
"success"
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
expect
(
create_develop_builds
).
to
be_truthy
commit
.
builds
.
update_all
(
status:
"success"
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
4
)
expect
(
commit
.
refs
.
size
).
to
eq
(
2
)
expect
(
commit
.
builds
.
pluck
(
:name
).
uniq
.
size
).
to
eq
(
2
)
end
end
context
'for build triggers'
do
let
(
:trigger
)
{
FactoryGirl
.
create
:ci_trigger
,
project:
project
}
let
(
:trigger_request
)
{
FactoryGirl
.
create
:ci_trigger_request
,
commit:
commit
,
trigger:
trigger
}
it
'creates builds'
do
expect
(
create_builds
(
trigger_request
)).
to
be_truthy
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
end
it
'rebuilds commit'
do
expect
(
create_builds
).
to
be_truthy
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
expect
(
create_builds
(
trigger_request
)).
to
be_truthy
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
4
)
end
it
'creates next builds'
do
expect
(
create_builds
(
trigger_request
)).
to
be_truthy
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
commit
.
builds
.
update_all
(
status:
"success"
)
expect
(
create_next_builds
).
to
be_truthy
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
4
)
end
context
'for [ci skip]'
do
before
do
allow
(
commit
).
to
receive
(
:git_commit_message
)
{
'message [ci skip]'
}
end
it
'rebuilds commit'
do
expect
(
commit
.
status
).
to
eq
(
'skipped'
)
expect
(
create_builds
).
to
be_truthy
# since everything in Ci::Commit is cached we need to fetch a new object
new_commit
=
Ci
::
Commit
.
find_by_id
(
commit
.
id
)
expect
(
new_commit
.
status
).
to
eq
(
'pending'
)
end
end
end
context
'custom stage with first job allowed to fail'
do
context
'custom stage with first job allowed to fail'
do
let
(
:yaml
)
do
let
(
:yaml
)
do
{
{
...
@@ -284,6 +175,7 @@ describe Ci::Commit, models: true do
...
@@ -284,6 +175,7 @@ describe Ci::Commit, models: true do
commit
.
builds
.
running_or_pending
.
each
(
&
:success
)
commit
.
builds
.
running_or_pending
.
each
(
&
:success
)
expect
(
commit
.
builds
.
pluck
(
:status
)).
to
contain_exactly
(
'success'
,
'success'
,
'success'
,
'success'
)
expect
(
commit
.
builds
.
pluck
(
:status
)).
to
contain_exactly
(
'success'
,
'success'
,
'success'
,
'success'
)
commit
.
reload
expect
(
commit
.
status
).
to
eq
(
'success'
)
expect
(
commit
.
status
).
to
eq
(
'success'
)
end
end
...
@@ -306,6 +198,7 @@ describe Ci::Commit, models: true do
...
@@ -306,6 +198,7 @@ describe Ci::Commit, models: true do
commit
.
builds
.
running_or_pending
.
each
(
&
:success
)
commit
.
builds
.
running_or_pending
.
each
(
&
:success
)
expect
(
commit
.
builds
.
pluck
(
:status
)).
to
contain_exactly
(
'success'
,
'failed'
,
'success'
,
'success'
)
expect
(
commit
.
builds
.
pluck
(
:status
)).
to
contain_exactly
(
'success'
,
'failed'
,
'success'
,
'success'
)
commit
.
reload
expect
(
commit
.
status
).
to
eq
(
'failed'
)
expect
(
commit
.
status
).
to
eq
(
'failed'
)
end
end
...
@@ -329,6 +222,7 @@ describe Ci::Commit, models: true do
...
@@ -329,6 +222,7 @@ describe Ci::Commit, models: true do
expect
(
commit
.
builds
.
pluck
(
:name
)).
to
contain_exactly
(
'build'
,
'test'
,
'test_failure'
,
'cleanup'
)
expect
(
commit
.
builds
.
pluck
(
:name
)).
to
contain_exactly
(
'build'
,
'test'
,
'test_failure'
,
'cleanup'
)
expect
(
commit
.
builds
.
pluck
(
:status
)).
to
contain_exactly
(
'success'
,
'failed'
,
'failed'
,
'success'
)
expect
(
commit
.
builds
.
pluck
(
:status
)).
to
contain_exactly
(
'success'
,
'failed'
,
'failed'
,
'success'
)
commit
.
reload
expect
(
commit
.
status
).
to
eq
(
'failed'
)
expect
(
commit
.
status
).
to
eq
(
'failed'
)
end
end
...
@@ -351,6 +245,7 @@ describe Ci::Commit, models: true do
...
@@ -351,6 +245,7 @@ describe Ci::Commit, models: true do
commit
.
builds
.
running_or_pending
.
each
(
&
:success
)
commit
.
builds
.
running_or_pending
.
each
(
&
:success
)
expect
(
commit
.
builds
.
pluck
(
:status
)).
to
contain_exactly
(
'success'
,
'success'
,
'failed'
,
'success'
)
expect
(
commit
.
builds
.
pluck
(
:status
)).
to
contain_exactly
(
'success'
,
'success'
,
'failed'
,
'success'
)
commit
.
reload
expect
(
commit
.
status
).
to
eq
(
'failed'
)
expect
(
commit
.
status
).
to
eq
(
'failed'
)
end
end
end
end
...
...
spec/models/commit_status_spec.rb
View file @
af7214d0
...
@@ -163,21 +163,7 @@ describe CommitStatus, models: true do
...
@@ -163,21 +163,7 @@ describe CommitStatus, models: true do
end
end
it
'return unique statuses'
do
it
'return unique statuses'
do
is_expected
.
to
eq
([
@commit2
,
@commit3
,
@commit4
,
@commit5
])
is_expected
.
to
eq
([
@commit4
,
@commit5
])
end
end
describe
:for_ref
do
subject
{
CommitStatus
.
for_ref
(
'bb'
).
order
(
:id
)
}
before
do
@commit1
=
FactoryGirl
.
create
:commit_status
,
commit:
commit
,
name:
'aa'
,
ref:
'bb'
,
status:
'running'
@commit2
=
FactoryGirl
.
create
:commit_status
,
commit:
commit
,
name:
'cc'
,
ref:
'cc'
,
status:
'pending'
@commit3
=
FactoryGirl
.
create
:commit_status
,
commit:
commit
,
name:
'aa'
,
ref:
nil
,
status:
'success'
end
it
'return statuses with equal and nil ref set'
do
is_expected
.
to
eq
([
@commit1
])
end
end
end
end
...
...
spec/models/merge_request_spec.rb
View file @
af7214d0
...
@@ -404,12 +404,12 @@ describe MergeRequest, models: true do
...
@@ -404,12 +404,12 @@ describe MergeRequest, models: true do
describe
'when the source project exists'
do
describe
'when the source project exists'
do
it
'returns the latest commit'
do
it
'returns the latest commit'
do
commit
=
double
(
:commit
,
id:
'123abc'
)
commit
=
double
(
:commit
,
id:
'123abc'
)
ci_commit
=
double
(
:ci_commit
)
ci_commit
=
double
(
:ci_commit
,
ref:
'master'
)
allow
(
subject
).
to
receive
(
:last_commit
).
and_return
(
commit
)
allow
(
subject
).
to
receive
(
:last_commit
).
and_return
(
commit
)
expect
(
subject
.
source_project
).
to
receive
(
:ci_commit
).
expect
(
subject
.
source_project
).
to
receive
(
:ci_commit
).
with
(
'123abc'
).
with
(
'123abc'
,
'master'
).
and_return
(
ci_commit
)
and_return
(
ci_commit
)
expect
(
subject
.
ci_commit
).
to
eq
(
ci_commit
)
expect
(
subject
.
ci_commit
).
to
eq
(
ci_commit
)
...
...
spec/models/project_spec.rb
View file @
af7214d0
...
@@ -441,9 +441,9 @@ describe Project, models: true do
...
@@ -441,9 +441,9 @@ describe Project, models: true do
describe
:ci_commit
do
describe
:ci_commit
do
let
(
:project
)
{
create
:project
}
let
(
:project
)
{
create
:project
}
let
(
:commit
)
{
create
:ci_commit
,
project:
project
}
let
(
:commit
)
{
create
:ci_commit
,
project:
project
,
ref:
'master'
}
it
{
expect
(
project
.
ci_commit
(
commit
.
sha
)).
to
eq
(
commit
)
}
it
{
expect
(
project
.
ci_commit
(
commit
.
sha
,
'master'
)).
to
eq
(
commit
)
}
end
end
describe
:builds_enabled
do
describe
:builds_enabled
do
...
...
spec/requests/api/builds_spec.rb
View file @
af7214d0
...
@@ -59,7 +59,7 @@ describe API::API, api: true do
...
@@ -59,7 +59,7 @@ describe API::API, api: true do
describe
'GET /projects/:id/repository/commits/:sha/builds'
do
describe
'GET /projects/:id/repository/commits/:sha/builds'
do
before
do
before
do
project
.
ensure_ci_commit
(
commit
.
sha
)
project
.
ensure_ci_commit
(
commit
.
sha
,
'master'
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
sha
}
/builds"
,
api_user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
sha
}
/builds"
,
api_user
)
end
end
...
...
spec/requests/api/commit_status_spec.rb
View file @
af7214d0
...
@@ -16,7 +16,8 @@ describe API::CommitStatus, api: true do
...
@@ -16,7 +16,8 @@ describe API::CommitStatus, api: true do
let
(
:get_url
)
{
"/projects/
#{
project
.
id
}
/repository/commits/
#{
sha
}
/statuses"
}
let
(
:get_url
)
{
"/projects/
#{
project
.
id
}
/repository/commits/
#{
sha
}
/statuses"
}
context
'ci commit exists'
do
context
'ci commit exists'
do
let!
(
:ci_commit
)
{
project
.
ensure_ci_commit
(
commit
.
id
)
}
let!
(
:master
)
{
project
.
ci_commits
.
create
(
sha:
commit
.
id
,
ref:
'master'
)
}
let!
(
:develop
)
{
project
.
ci_commits
.
create
(
sha:
commit
.
id
,
ref:
'develop'
)
}
it_behaves_like
'a paginated resources'
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
get_url
,
reporter
)
}
let
(
:request
)
{
get
api
(
get_url
,
reporter
)
}
...
@@ -25,16 +26,16 @@ describe API::CommitStatus, api: true do
...
@@ -25,16 +26,16 @@ describe API::CommitStatus, api: true do
context
"reporter user"
do
context
"reporter user"
do
let
(
:statuses_id
)
{
json_response
.
map
{
|
status
|
status
[
'id'
]
}
}
let
(
:statuses_id
)
{
json_response
.
map
{
|
status
|
status
[
'id'
]
}
}
def
create_status
(
opts
=
{})
def
create_status
(
commit
,
opts
=
{})
create
(
:commit_status
,
{
commit:
c
i_commit
}.
merge
(
opts
))
create
(
:commit_status
,
{
commit:
c
ommit
,
ref:
commit
.
ref
}.
merge
(
opts
))
end
end
let!
(
:status1
)
{
create_status
(
status:
'running'
)
}
let!
(
:status1
)
{
create_status
(
master
,
status:
'running'
)
}
let!
(
:status2
)
{
create_status
(
name:
'coverage'
,
status:
'pending'
)
}
let!
(
:status2
)
{
create_status
(
master
,
name:
'coverage'
,
status:
'pending'
)
}
let!
(
:status3
)
{
create_status
(
ref:
'develop'
,
status:
'running'
,
allow_failure:
true
)
}
let!
(
:status3
)
{
create_status
(
develop
,
status:
'running'
,
allow_failure:
true
)
}
let!
(
:status4
)
{
create_status
(
name:
'coverage'
,
status:
'success'
)
}
let!
(
:status4
)
{
create_status
(
master
,
name:
'coverage'
,
status:
'success'
)
}
let!
(
:status5
)
{
create_status
(
name:
'coverage'
,
ref:
'develop
'
,
status:
'success'
)
}
let!
(
:status5
)
{
create_status
(
develop
,
name:
'coverage
'
,
status:
'success'
)
}
let!
(
:status6
)
{
create_status
(
status:
'success'
)
}
let!
(
:status6
)
{
create_status
(
master
,
status:
'success'
)
}
context
'latest commit statuses'
do
context
'latest commit statuses'
do
before
{
get
api
(
get_url
,
reporter
)
}
before
{
get
api
(
get_url
,
reporter
)
}
...
...
spec/requests/api/commits_spec.rb
View file @
af7214d0
...
@@ -51,11 +51,11 @@ describe API::API, api: true do
...
@@ -51,11 +51,11 @@ describe API::API, api: true do
it
"should return not_found for CI status"
do
it
"should return not_found for CI status"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
project
.
repository
.
commit
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
project
.
repository
.
commit
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'status'
]).
to
eq
(
'not_found'
)
expect
(
json_response
[
'status'
]).
to
be_nil
end
end
it
"should return status for CI"
do
it
"should return status for CI"
do
ci_commit
=
project
.
ensure_ci_commit
(
project
.
repository
.
commit
.
sha
)
ci_commit
=
project
.
ensure_ci_commit
(
project
.
repository
.
commit
.
sha
,
'master'
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
project
.
repository
.
commit
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
project
.
repository
.
commit
.
id
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'status'
]).
to
eq
(
ci_commit
.
status
)
expect
(
json_response
[
'status'
]).
to
eq
(
ci_commit
.
status
)
...
...
spec/requests/ci/api/builds_spec.rb
View file @
af7214d0
...
@@ -20,8 +20,8 @@ describe Ci::API::API do
...
@@ -20,8 +20,8 @@ describe Ci::API::API do
describe
"POST /builds/register"
do
describe
"POST /builds/register"
do
it
"should start a build"
do
it
"should start a build"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
'master'
,
false
,
nil
)
commit
.
create_builds
(
nil
)
build
=
commit
.
builds
.
first
build
=
commit
.
builds
.
first
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
@@ -56,8 +56,8 @@ describe Ci::API::API do
...
@@ -56,8 +56,8 @@ describe Ci::API::API do
end
end
it
"returns options"
do
it
"returns options"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
'master'
,
false
,
nil
)
commit
.
create_builds
(
nil
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
@@ -66,8 +66,8 @@ describe Ci::API::API do
...
@@ -66,8 +66,8 @@ describe Ci::API::API do
end
end
it
"returns variables"
do
it
"returns variables"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
'master'
,
false
,
nil
)
commit
.
create_builds
(
nil
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
@@ -83,10 +83,10 @@ describe Ci::API::API do
...
@@ -83,10 +83,10 @@ describe Ci::API::API do
it
"returns variables for triggers"
do
it
"returns variables for triggers"
do
trigger
=
FactoryGirl
.
create
(
:ci_trigger
,
project:
project
)
trigger
=
FactoryGirl
.
create
(
:ci_trigger
,
project:
project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
trigger_request
=
FactoryGirl
.
create
(
:ci_trigger_request_with_variables
,
commit:
commit
,
trigger:
trigger
)
trigger_request
=
FactoryGirl
.
create
(
:ci_trigger_request_with_variables
,
commit:
commit
,
trigger:
trigger
)
commit
.
create_builds
(
'master'
,
false
,
nil
,
trigger_request
)
commit
.
create_builds
(
nil
,
trigger_request
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
@@ -103,8 +103,8 @@ describe Ci::API::API do
...
@@ -103,8 +103,8 @@ describe Ci::API::API do
end
end
it
"returns dependent builds"
do
it
"returns dependent builds"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
'master'
,
false
,
nil
,
nil
)
commit
.
create_builds
(
nil
,
nil
)
commit
.
builds
.
where
(
stage:
'test'
).
each
(
&
:success
)
commit
.
builds
.
where
(
stage:
'test'
).
each
(
&
:success
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
...
spec/services/ci/create_builds_service_spec.rb
View file @
af7214d0
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
CreateBuildsService
,
services:
true
do
describe
Ci
::
CreateBuildsService
,
services:
true
do
let
(
:commit
)
{
create
(
:ci_commit
)
}
let
(
:commit
)
{
create
(
:ci_commit
,
ref:
'master'
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
describe
'#execute'
do
describe
'#execute'
do
...
@@ -9,7 +9,7 @@ describe Ci::CreateBuildsService, services: true do
...
@@ -9,7 +9,7 @@ describe Ci::CreateBuildsService, services: true do
#
#
subject
do
subject
do
described_class
.
new
.
execute
(
commit
,
'test'
,
'master'
,
nil
,
user
,
nil
,
status
)
described_class
.
new
(
commit
).
execute
(
commit
,
nil
,
user
,
status
)
end
end
context
'next builds available'
do
context
'next builds available'
do
...
...
spec/services/ci/image_for_build_service_spec.rb
View file @
af7214d0
...
@@ -5,7 +5,7 @@ module Ci
...
@@ -5,7 +5,7 @@ module Ci
let
(
:service
)
{
ImageForBuildService
.
new
}
let
(
:service
)
{
ImageForBuildService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
(
:empty_project
)
}
let
(
:project
)
{
FactoryGirl
.
create
(
:empty_project
)
}
let
(
:commit_sha
)
{
'01234567890123456789'
}
let
(
:commit_sha
)
{
'01234567890123456789'
}
let
(
:commit
)
{
project
.
ensure_ci_commit
(
commit_sha
)
}
let
(
:commit
)
{
project
.
ensure_ci_commit
(
commit_sha
,
'master'
)
}
let
(
:build
)
{
FactoryGirl
.
create
(
:ci_build
,
commit:
commit
)
}
let
(
:build
)
{
FactoryGirl
.
create
(
:ci_build
,
commit:
commit
)
}
describe
:execute
do
describe
:execute
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