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
20c7144e
Commit
20c7144e
authored
Jun 03, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename all `[ci_]commit` to `[ci_]pipeline` in specs and features
parent
8ce1896b
Changes
39
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
373 additions
and
375 deletions
+373
-375
features/steps/project/commits/commits.rb
features/steps/project/commits/commits.rb
+2
-2
features/steps/project/merge_requests.rb
features/steps/project/merge_requests.rb
+2
-2
features/steps/shared/builds.rb
features/steps/shared/builds.rb
+3
-3
features/steps/shared/project.rb
features/steps/shared/project.rb
+1
-1
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+1
-1
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+1
-1
spec/factories/ci/commits.rb
spec/factories/ci/commits.rb
+5
-5
spec/factories/commit_statuses.rb
spec/factories/commit_statuses.rb
+1
-1
spec/features/admin/admin_builds_spec.rb
spec/features/admin/admin_builds_spec.rb
+13
-13
spec/features/admin/admin_runners_spec.rb
spec/features/admin/admin_runners_spec.rb
+2
-2
spec/features/builds_spec.rb
spec/features/builds_spec.rb
+1
-1
spec/features/commits_spec.rb
spec/features/commits_spec.rb
+28
-28
spec/features/merge_requests/created_from_fork_spec.rb
spec/features/merge_requests/created_from_fork_spec.rb
+1
-1
spec/features/merge_requests/merge_when_build_succeeds_spec.rb
...features/merge_requests/merge_when_build_succeeds_spec.rb
+3
-3
spec/features/pipelines_spec.rb
spec/features/pipelines_spec.rb
+3
-3
spec/features/projects/commit/builds_spec.rb
spec/features/projects/commit/builds_spec.rb
+1
-1
spec/features/security/project/public_access_spec.rb
spec/features/security/project/public_access_spec.rb
+2
-2
spec/lib/ci/charts_spec.rb
spec/lib/ci/charts_spec.rb
+5
-5
spec/lib/gitlab/badge/build_spec.rb
spec/lib/gitlab/badge/build_spec.rb
+2
-3
spec/models/build_spec.rb
spec/models/build_spec.rb
+27
-27
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+135
-135
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+22
-22
spec/models/generic_commit_status_spec.rb
spec/models/generic_commit_status_spec.rb
+2
-2
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+8
-8
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+9
-9
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+2
-2
spec/requests/api/triggers_spec.rb
spec/requests/api/triggers_spec.rb
+6
-6
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+24
-24
spec/requests/ci/api/triggers_spec.rb
spec/requests/ci/api/triggers_spec.rb
+6
-6
spec/services/ci/create_builds_service_spec.rb
spec/services/ci/create_builds_service_spec.rb
+2
-2
spec/services/ci/create_trigger_request_service_spec.rb
spec/services/ci/create_trigger_request_service_spec.rb
+3
-3
spec/services/ci/register_build_service_spec.rb
spec/services/ci/register_build_service_spec.rb
+2
-2
spec/services/create_commit_builds_service_spec.rb
spec/services/create_commit_builds_service_spec.rb
+39
-39
spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb
.../merge_requests/add_todo_when_build_fails_service_spec.rb
+1
-1
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
.../merge_requests/merge_when_build_succeeds_service_spec.rb
+1
-1
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+1
-2
spec/support/stub_gitlab_calls.rb
spec/support/stub_gitlab_calls.rb
+3
-3
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+2
-2
No files found.
features/steps/project/commits/commits.rb
View file @
20c7144e
...
@@ -164,8 +164,8 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
...
@@ -164,8 +164,8 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
step
'commit has ci status'
do
step
'commit has ci status'
do
@project
.
enable_ci
@project
.
enable_ci
ci_commit
=
create
:ci_commit
,
project:
@project
,
sha:
sample_commit
.
id
pipeline
=
create
:ci_pipeline
,
project:
@project
,
sha:
sample_commit
.
id
create
:ci_build
,
pipeline:
ci_commit
create
:ci_build
,
pipeline:
pipeline
end
end
step
'repository contains ".gitlab-ci.yml" file'
do
step
'repository contains ".gitlab-ci.yml" file'
do
...
...
features/steps/project/merge_requests.rb
View file @
20c7144e
...
@@ -519,8 +519,8 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
...
@@ -519,8 +519,8 @@ 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
,
ref:
merge_request
.
source_branch
pipeline
=
create
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
last_commit
.
id
,
ref:
merge_request
.
source_branch
create
:ci_build
,
pipeline:
ci_commit
create
:ci_build
,
pipeline:
pipeline
end
end
step
'I should see merge request "Bug NS-05" with CI status'
do
step
'I should see merge request "Bug NS-05" with CI status'
do
...
...
features/steps/shared/builds.rb
View file @
20c7144e
...
@@ -10,8 +10,8 @@ module SharedBuilds
...
@@ -10,8 +10,8 @@ module SharedBuilds
end
end
step
'project has a recent build'
do
step
'project has a recent build'
do
@
ci_commit
=
create
(
:ci_commit
,
project:
@project
,
sha:
@project
.
commit
.
sha
,
ref:
'master'
)
@
pipeline
=
create
(
:ci_pipeline
,
project:
@project
,
sha:
@project
.
commit
.
sha
,
ref:
'master'
)
@build
=
create
(
:ci_build_with_coverage
,
commit:
@ci_commit
)
@build
=
create
(
:ci_build_with_coverage
,
pipeline:
@pipeline
)
end
end
step
'recent build is successful'
do
step
'recent build is successful'
do
...
@@ -23,7 +23,7 @@ module SharedBuilds
...
@@ -23,7 +23,7 @@ module SharedBuilds
end
end
step
'project has another build that is running'
do
step
'project has another build that is running'
do
create
(
:ci_build
,
pipeline:
@
ci_commit
,
name:
'second build'
,
status:
'running'
)
create
(
:ci_build
,
pipeline:
@
pipeline
,
name:
'second build'
,
status:
'running'
)
end
end
step
'I visit recent build details page'
do
step
'I visit recent build details page'
do
...
...
features/steps/shared/project.rb
View file @
20c7144e
...
@@ -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
,
ref:
'master'
,
status:
'skipped'
create
:ci_
pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
'master'
,
status:
'skipped'
end
end
step
'I should see last commit with CI status'
do
step
'I should see last commit with CI status'
do
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
20c7144e
...
@@ -250,7 +250,7 @@ describe Projects::MergeRequestsController do
...
@@ -250,7 +250,7 @@ describe Projects::MergeRequestsController do
end
end
before
do
before
do
create
(
:ci_empty_
commit
,
project:
project
,
sha:
merge_request
.
source_sha
,
ref:
merge_request
.
source_branch
)
create
(
:ci_empty_
pipeline
,
project:
project
,
sha:
merge_request
.
source_sha
,
ref:
merge_request
.
source_branch
)
end
end
it
'returns :merge_when_build_succeeds'
do
it
'returns :merge_when_build_succeeds'
do
...
...
spec/factories/ci/builds.rb
View file @
20c7144e
...
@@ -16,7 +16,7 @@ FactoryGirl.define do
...
@@ -16,7 +16,7 @@ FactoryGirl.define do
}
}
end
end
pipeline
factory: :ci_
commit
pipeline
factory: :ci_
pipeline
trait
:success
do
trait
:success
do
status
'success'
status
'success'
...
...
spec/factories/ci/commits.rb
View file @
20c7144e
...
@@ -17,30 +17,30 @@
...
@@ -17,30 +17,30 @@
#
#
FactoryGirl
.
define
do
FactoryGirl
.
define
do
factory
:ci_empty_
commit
,
class:
Ci
::
Pipeline
do
factory
:ci_empty_
pipeline
,
class:
Ci
::
Pipeline
do
sha
'97de212e80737a608d939f648d959671fb0a0142'
sha
'97de212e80737a608d939f648d959671fb0a0142'
project
factory: :empty_project
project
factory: :empty_project
factory
:ci_
commit
_without_jobs
do
factory
:ci_
pipeline
_without_jobs
do
after
(
:build
)
do
|
commit
|
after
(
:build
)
do
|
commit
|
allow
(
commit
).
to
receive
(
:ci_yaml_file
)
{
YAML
.
dump
({})
}
allow
(
commit
).
to
receive
(
:ci_yaml_file
)
{
YAML
.
dump
({})
}
end
end
end
end
factory
:ci_
commit
_with_one_job
do
factory
:ci_
pipeline
_with_one_job
do
after
(
:build
)
do
|
commit
|
after
(
:build
)
do
|
commit
|
allow
(
commit
).
to
receive
(
:ci_yaml_file
)
{
YAML
.
dump
({
rspec:
{
script:
"ls"
}
})
}
allow
(
commit
).
to
receive
(
:ci_yaml_file
)
{
YAML
.
dump
({
rspec:
{
script:
"ls"
}
})
}
end
end
end
end
factory
:ci_
commit_with_two_jobs
do
factory
:ci_
pipeline_with_two_job
do
after
(
:build
)
do
|
commit
|
after
(
:build
)
do
|
commit
|
allow
(
commit
).
to
receive
(
:ci_yaml_file
)
{
YAML
.
dump
({
rspec:
{
script:
"ls"
},
spinach:
{
script:
"ls"
}
})
}
allow
(
commit
).
to
receive
(
:ci_yaml_file
)
{
YAML
.
dump
({
rspec:
{
script:
"ls"
},
spinach:
{
script:
"ls"
}
})
}
end
end
end
end
factory
:ci_
commit
do
factory
:ci_
pipeline
do
after
(
:build
)
do
|
commit
|
after
(
:build
)
do
|
commit
|
allow
(
commit
).
to
receive
(
:ci_yaml_file
)
{
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
}
allow
(
commit
).
to
receive
(
:ci_yaml_file
)
{
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
}
end
end
...
...
spec/factories/commit_statuses.rb
View file @
20c7144e
...
@@ -3,7 +3,7 @@ FactoryGirl.define do
...
@@ -3,7 +3,7 @@ FactoryGirl.define do
name
'default'
name
'default'
status
'success'
status
'success'
description
'commit status'
description
'commit status'
pipeline
factory: :ci_
commit
_with_one_job
pipeline
factory: :ci_
pipeline
_with_one_job
started_at
'Tue, 26 Jan 2016 08:21:42 +0100'
started_at
'Tue, 26 Jan 2016 08:21:42 +0100'
finished_at
'Tue, 26 Jan 2016 08:23:42 +0100'
finished_at
'Tue, 26 Jan 2016 08:23:42 +0100'
...
...
spec/features/admin/admin_builds_spec.rb
View file @
20c7144e
...
@@ -6,15 +6,15 @@ describe 'Admin Builds' do
...
@@ -6,15 +6,15 @@ describe 'Admin Builds' do
end
end
describe
'GET /admin/builds'
do
describe
'GET /admin/builds'
do
let
(
:
commit
)
{
create
(
:ci_commit
)
}
let
(
:
pipeline
)
{
create
(
:ci_pipeline
)
}
context
'All tab'
do
context
'All tab'
do
context
'when have builds'
do
context
'when have builds'
do
it
'shows all builds'
do
it
'shows all builds'
do
create
(
:ci_build
,
pipeline:
commit
,
status: :pending
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :pending
)
create
(
:ci_build
,
pipeline:
commit
,
status: :running
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :running
)
create
(
:ci_build
,
pipeline:
commit
,
status: :success
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
)
create
(
:ci_build
,
pipeline:
commit
,
status: :failed
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :failed
)
visit
admin_builds_path
visit
admin_builds_path
...
@@ -39,9 +39,9 @@ describe 'Admin Builds' do
...
@@ -39,9 +39,9 @@ describe 'Admin Builds' do
context
'Running tab'
do
context
'Running tab'
do
context
'when have running builds'
do
context
'when have running builds'
do
it
'shows running builds'
do
it
'shows running builds'
do
build1
=
create
(
:ci_build
,
pipeline:
commit
,
status: :pending
)
build1
=
create
(
:ci_build
,
pipeline:
pipeline
,
status: :pending
)
build2
=
create
(
:ci_build
,
pipeline:
commit
,
status: :success
)
build2
=
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
)
build3
=
create
(
:ci_build
,
pipeline:
commit
,
status: :failed
)
build3
=
create
(
:ci_build
,
pipeline:
pipeline
,
status: :failed
)
visit
admin_builds_path
(
scope: :running
)
visit
admin_builds_path
(
scope: :running
)
...
@@ -55,7 +55,7 @@ describe 'Admin Builds' do
...
@@ -55,7 +55,7 @@ describe 'Admin Builds' do
context
'when have no builds running'
do
context
'when have no builds running'
do
it
'shows a message'
do
it
'shows a message'
do
create
(
:ci_build
,
pipeline:
commit
,
status: :success
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
)
visit
admin_builds_path
(
scope: :running
)
visit
admin_builds_path
(
scope: :running
)
...
@@ -69,9 +69,9 @@ describe 'Admin Builds' do
...
@@ -69,9 +69,9 @@ describe 'Admin Builds' do
context
'Finished tab'
do
context
'Finished tab'
do
context
'when have finished builds'
do
context
'when have finished builds'
do
it
'shows finished builds'
do
it
'shows finished builds'
do
build1
=
create
(
:ci_build
,
pipeline:
commit
,
status: :pending
)
build1
=
create
(
:ci_build
,
pipeline:
pipeline
,
status: :pending
)
build2
=
create
(
:ci_build
,
pipeline:
commit
,
status: :running
)
build2
=
create
(
:ci_build
,
pipeline:
pipeline
,
status: :running
)
build3
=
create
(
:ci_build
,
pipeline:
commit
,
status: :success
)
build3
=
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
)
visit
admin_builds_path
(
scope: :finished
)
visit
admin_builds_path
(
scope: :finished
)
...
@@ -85,7 +85,7 @@ describe 'Admin Builds' do
...
@@ -85,7 +85,7 @@ describe 'Admin Builds' do
context
'when have no builds finished'
do
context
'when have no builds finished'
do
it
'shows a message'
do
it
'shows a message'
do
create
(
:ci_build
,
pipeline:
commit
,
status: :running
)
create
(
:ci_build
,
pipeline:
pipeline
,
status: :running
)
visit
admin_builds_path
(
scope: :finished
)
visit
admin_builds_path
(
scope: :finished
)
...
...
spec/features/admin/admin_runners_spec.rb
View file @
20c7144e
...
@@ -8,8 +8,8 @@ describe "Admin Runners" do
...
@@ -8,8 +8,8 @@ describe "Admin Runners" do
describe
"Runners page"
do
describe
"Runners page"
do
before
do
before
do
runner
=
FactoryGirl
.
create
(
:ci_runner
)
runner
=
FactoryGirl
.
create
(
:ci_runner
)
commit
=
FactoryGirl
.
create
(
:ci_commit
)
pipeline
=
FactoryGirl
.
create
(
:ci_pipeline
)
FactoryGirl
.
create
(
:ci_build
,
pipeline:
commit
,
runner_id:
runner
.
id
)
FactoryGirl
.
create
(
:ci_build
,
pipeline:
pipeline
,
runner_id:
runner
.
id
)
visit
admin_runners_path
visit
admin_runners_path
end
end
...
...
spec/features/builds_spec.rb
View file @
20c7144e
...
@@ -5,7 +5,7 @@ describe "Builds" do
...
@@ -5,7 +5,7 @@ describe "Builds" do
before
do
before
do
login_as
(
:user
)
login_as
(
:user
)
@commit
=
FactoryGirl
.
create
:ci_
commit
@commit
=
FactoryGirl
.
create
:ci_
pipeline
@build
=
FactoryGirl
.
create
:ci_build
,
pipeline:
@commit
@build
=
FactoryGirl
.
create
:ci_build
,
pipeline:
@commit
@project
=
@commit
.
project
@project
=
@commit
.
project
@project
.
team
<<
[
@user
,
:developer
]
@project
.
team
<<
[
@user
,
:developer
]
...
...
spec/features/commits_spec.rb
View file @
20c7144e
...
@@ -8,15 +8,15 @@ describe 'Commits' do
...
@@ -8,15 +8,15 @@ describe 'Commits' do
describe
'CI'
do
describe
'CI'
do
before
do
before
do
login_as
:user
login_as
:user
stub_ci_
commit
_to_return_yaml_file
stub_ci_
pipeline
_to_return_yaml_file
end
end
let!
(
:
commit
)
do
let!
(
:
pipeline
)
do
FactoryGirl
.
create
:ci_
commit
,
project:
project
,
sha:
project
.
commit
.
sha
FactoryGirl
.
create
:ci_
pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
end
end
context
'commit status is Generic Commit Status'
do
context
'commit status is Generic Commit Status'
do
let!
(
:status
)
{
FactoryGirl
.
create
:generic_commit_status
,
pipeline:
commit
}
let!
(
:status
)
{
FactoryGirl
.
create
:generic_commit_status
,
pipeline:
pipeline
}
before
do
before
do
project
.
team
<<
[
@user
,
:reporter
]
project
.
team
<<
[
@user
,
:reporter
]
...
@@ -24,10 +24,10 @@ describe 'Commits' do
...
@@ -24,10 +24,10 @@ describe 'Commits' do
describe
'Commit builds'
do
describe
'Commit builds'
do
before
do
before
do
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
end
end
it
{
expect
(
page
).
to
have_content
commit
.
sha
[
0
..
7
]
}
it
{
expect
(
page
).
to
have_content
pipeline
.
sha
[
0
..
7
]
}
it
'contains generic commit status build'
do
it
'contains generic commit status build'
do
page
.
within
(
'.table-holder'
)
do
page
.
within
(
'.table-holder'
)
do
...
@@ -39,7 +39,7 @@ describe 'Commits' do
...
@@ -39,7 +39,7 @@ describe 'Commits' do
end
end
context
'commit status is Ci Build'
do
context
'commit status is Ci Build'
do
let!
(
:build
)
{
FactoryGirl
.
create
:ci_build
,
pipeline:
commit
}
let!
(
:build
)
{
FactoryGirl
.
create
:ci_build
,
pipeline:
pipeline
}
let
(
:artifacts_file
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:artifacts_file
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
context
'when logged as developer'
do
context
'when logged as developer'
do
...
@@ -53,7 +53,7 @@ describe 'Commits' do
...
@@ -53,7 +53,7 @@ describe 'Commits' do
end
end
it
'should show build status'
do
it
'should show build status'
do
page
.
within
(
"//li[@id='commit-
#{
commit
.
short_sha
}
']"
)
do
page
.
within
(
"//li[@id='commit-
#{
pipeline
.
short_sha
}
']"
)
do
expect
(
page
).
to
have_css
(
".ci-status-link"
)
expect
(
page
).
to
have_css
(
".ci-status-link"
)
end
end
end
end
...
@@ -61,12 +61,12 @@ describe 'Commits' do
...
@@ -61,12 +61,12 @@ describe 'Commits' do
describe
'Commit builds'
do
describe
'Commit builds'
do
before
do
before
do
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
end
end
it
{
expect
(
page
).
to
have_content
commit
.
sha
[
0
..
7
]
}
it
{
expect
(
page
).
to
have_content
pipeline
.
sha
[
0
..
7
]
}
it
{
expect
(
page
).
to
have_content
commit
.
git_commit_message
}
it
{
expect
(
page
).
to
have_content
pipeline
.
git_commit_message
}
it
{
expect
(
page
).
to
have_content
commit
.
git_author_name
}
it
{
expect
(
page
).
to
have_content
pipeline
.
git_author_name
}
end
end
context
'Download artifacts'
do
context
'Download artifacts'
do
...
@@ -75,7 +75,7 @@ describe 'Commits' do
...
@@ -75,7 +75,7 @@ describe 'Commits' do
end
end
it
do
it
do
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
click_on
'Download artifacts'
click_on
'Download artifacts'
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
eq
(
artifacts_file
.
content_type
)
expect
(
page
.
response_headers
[
'Content-Type'
]).
to
eq
(
artifacts_file
.
content_type
)
end
end
...
@@ -83,7 +83,7 @@ describe 'Commits' do
...
@@ -83,7 +83,7 @@ describe 'Commits' do
describe
'Cancel all builds'
do
describe
'Cancel all builds'
do
it
'cancels commit'
do
it
'cancels commit'
do
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
click_on
'Cancel running'
click_on
'Cancel running'
expect
(
page
).
to
have_content
'canceled'
expect
(
page
).
to
have_content
'canceled'
end
end
...
@@ -91,7 +91,7 @@ describe 'Commits' do
...
@@ -91,7 +91,7 @@ describe 'Commits' do
describe
'Cancel build'
do
describe
'Cancel build'
do
it
'cancels build'
do
it
'cancels build'
do
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
click_on
'Cancel'
click_on
'Cancel'
expect
(
page
).
to
have_content
'canceled'
expect
(
page
).
to
have_content
'canceled'
end
end
...
@@ -100,13 +100,13 @@ describe 'Commits' do
...
@@ -100,13 +100,13 @@ describe 'Commits' do
describe
'.gitlab-ci.yml not found warning'
do
describe
'.gitlab-ci.yml not found warning'
do
context
'ci builds enabled'
do
context
'ci builds enabled'
do
it
"does not show warning"
do
it
"does not show warning"
do
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
expect
(
page
).
not_to
have_content
'.gitlab-ci.yml not found in this commit'
expect
(
page
).
not_to
have_content
'.gitlab-ci.yml not found in this commit'
end
end
it
'shows warning'
do
it
'shows warning'
do
stub_ci_
commit
_yaml_file
(
nil
)
stub_ci_
pipeline
_yaml_file
(
nil
)
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
expect
(
page
).
to
have_content
'.gitlab-ci.yml not found in this commit'
expect
(
page
).
to
have_content
'.gitlab-ci.yml not found in this commit'
end
end
end
end
...
@@ -114,8 +114,8 @@ describe 'Commits' do
...
@@ -114,8 +114,8 @@ describe 'Commits' do
context
'ci builds disabled'
do
context
'ci builds disabled'
do
before
do
before
do
stub_ci_builds_disabled
stub_ci_builds_disabled
stub_ci_
commit
_yaml_file
(
nil
)
stub_ci_
pipeline
_yaml_file
(
nil
)
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
end
end
it
'does not show warning'
do
it
'does not show warning'
do
...
@@ -129,13 +129,13 @@ describe 'Commits' do
...
@@ -129,13 +129,13 @@ describe 'Commits' do
before
do
before
do
project
.
team
<<
[
@user
,
:reporter
]
project
.
team
<<
[
@user
,
:reporter
]
build
.
update_attributes
(
artifacts_file:
artifacts_file
)
build
.
update_attributes
(
artifacts_file:
artifacts_file
)
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
end
end
it
do
it
do
expect
(
page
).
to
have_content
commit
.
sha
[
0
..
7
]
expect
(
page
).
to
have_content
pipeline
.
sha
[
0
..
7
]
expect
(
page
).
to
have_content
commit
.
git_commit_message
expect
(
page
).
to
have_content
pipeline
.
git_commit_message
expect
(
page
).
to
have_content
commit
.
git_author_name
expect
(
page
).
to
have_content
pipeline
.
git_author_name
expect
(
page
).
to
have_link
(
'Download artifacts'
)
expect
(
page
).
to
have_link
(
'Download artifacts'
)
expect
(
page
).
not_to
have_link
(
'Cancel running'
)
expect
(
page
).
not_to
have_link
(
'Cancel running'
)
expect
(
page
).
not_to
have_link
(
'Retry failed'
)
expect
(
page
).
not_to
have_link
(
'Retry failed'
)
...
@@ -148,13 +148,13 @@ describe 'Commits' do
...
@@ -148,13 +148,13 @@ describe 'Commits' do
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
,
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
,
public_builds:
false
)
public_builds:
false
)
build
.
update_attributes
(
artifacts_file:
artifacts_file
)
build
.
update_attributes
(
artifacts_file:
artifacts_file
)
visit
ci_status_path
(
commit
)
visit
ci_status_path
(
pipeline
)
end
end
it
do
it
do
expect
(
page
).
to
have_content
commit
.
sha
[
0
..
7
]
expect
(
page
).
to
have_content
pipeline
.
sha
[
0
..
7
]
expect
(
page
).
to
have_content
commit
.
git_commit_message
expect
(
page
).
to
have_content
pipeline
.
git_commit_message
expect
(
page
).
to
have_content
commit
.
git_author_name
expect
(
page
).
to
have_content
pipeline
.
git_author_name
expect
(
page
).
not_to
have_link
(
'Download artifacts'
)
expect
(
page
).
not_to
have_link
(
'Download artifacts'
)
expect
(
page
).
not_to
have_link
(
'Cancel running'
)
expect
(
page
).
not_to
have_link
(
'Cancel running'
)
expect
(
page
).
not_to
have_link
(
'Retry failed'
)
expect
(
page
).
not_to
have_link
(
'Retry failed'
)
...
...
spec/features/merge_requests/created_from_fork_spec.rb
View file @
20c7144e
...
@@ -29,7 +29,7 @@ feature 'Merge request created from fork' do
...
@@ -29,7 +29,7 @@ feature 'Merge request created from fork' do
include
WaitForAjax
include
WaitForAjax
given
(
:pipeline
)
do
given
(
:pipeline
)
do
create
(
:ci_
commit_with_two_jobs
,
project:
fork_project
,
create
(
:ci_
pipeline_with_two_job
,
project:
fork_project
,
sha:
merge_request
.
last_commit
.
id
,
sha:
merge_request
.
last_commit
.
id
,
ref:
merge_request
.
source_branch
)
ref:
merge_request
.
source_branch
)
end
end
...
...
spec/features/merge_requests/merge_when_build_succeeds_spec.rb
View file @
20c7144e
...
@@ -12,7 +12,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
...
@@ -12,7 +12,7 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
end
end
context
"Active build for Merge Request"
do
context
"Active build for Merge Request"
do
let!
(
:
ci_commit
)
{
create
(
:ci_commit
,
project:
project
,
sha:
merge_request
.
last_commit
.
id
,
ref:
merge_request
.
source_branch
)
}
let!
(
:
pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
last_commit
.
id
,
ref:
merge_request
.
source_branch
)
}
let!
(
:ci_build
)
{
create
(
:ci_build
,
pipeline:
ci_commit
)
}
let!
(
:ci_build
)
{
create
(
:ci_build
,
pipeline:
ci_commit
)
}
before
do
before
do
...
@@ -47,8 +47,8 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
...
@@ -47,8 +47,8 @@ feature 'Merge When Build Succeeds', feature: true, js: true do
merge_user:
user
,
title:
"MepMep"
,
merge_when_build_succeeds:
true
)
merge_user:
user
,
title:
"MepMep"
,
merge_when_build_succeeds:
true
)
end
end
let!
(
:
ci_commit
)
{
create
(
:ci_commit
,
project:
project
,
sha:
merge_request
.
last_commit
.
id
,
ref:
merge_request
.
source_branch
)
}
let!
(
:
pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
sha:
merge_request
.
last_commit
.
id
,
ref:
merge_request
.
source_branch
)
}
let!
(
:ci_build
)
{
create
(
:ci_build
,
pipeline:
ci_commit
)
}
let!
(
:ci_build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
before
do
before
do
login_as
user
login_as
user
...
...
spec/features/pipelines_spec.rb
View file @
20c7144e
...
@@ -12,7 +12,7 @@ describe "Pipelines" do
...
@@ -12,7 +12,7 @@ describe "Pipelines" do
end
end
describe
'GET /:project/pipelines'
do
describe
'GET /:project/pipelines'
do
let!
(
:pipeline
)
{
create
(
:ci_
commit
,
project:
project
,
ref:
'master'
,
status:
'running'
)
}
let!
(
:pipeline
)
{
create
(
:ci_
pipeline
,
project:
project
,
ref:
'master'
,
status:
'running'
)
}
[
:all
,
:running
,
:branches
].
each
do
|
scope
|
[
:all
,
:running
,
:branches
].
each
do
|
scope
|
context
"displaying
#{
scope
}
"
do
context
"displaying
#{
scope
}
"
do
...
@@ -111,7 +111,7 @@ describe "Pipelines" do
...
@@ -111,7 +111,7 @@ describe "Pipelines" do
end
end
describe
'GET /:project/pipelines/:id'
do
describe
'GET /:project/pipelines/:id'
do
let
(
:pipeline
)
{
create
(
:ci_
commit
,
project:
project
,
ref:
'master'
)
}
let
(
:pipeline
)
{
create
(
:ci_
pipeline
,
project:
project
,
ref:
'master'
)
}
before
do
before
do
@success
=
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'build'
)
@success
=
create
(
:ci_build
,
:success
,
pipeline:
pipeline
,
stage:
'build'
,
name:
'build'
)
...
@@ -165,7 +165,7 @@ describe "Pipelines" do
...
@@ -165,7 +165,7 @@ describe "Pipelines" do
before
{
fill_in
(
'Create for'
,
with:
'master'
)
}
before
{
fill_in
(
'Create for'
,
with:
'master'
)
}
context
'with gitlab-ci.yml'
do
context
'with gitlab-ci.yml'
do
before
{
stub_ci_
commit
_to_return_yaml_file
}
before
{
stub_ci_
pipeline
_to_return_yaml_file
}
it
{
expect
{
click_on
'Create pipeline'
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
1
)
}
it
{
expect
{
click_on
'Create pipeline'
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
1
)
}
end
end
...
...
spec/features/projects/commit/builds_spec.rb
View file @
20c7144e
...
@@ -11,7 +11,7 @@ feature 'project commit builds' do
...
@@ -11,7 +11,7 @@ feature 'project commit builds' do
context
'when no builds triggered yet'
do
context
'when no builds triggered yet'
do
background
do
background
do
create
(
:ci_
commit
,
project:
project
,
create
(
:ci_
pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
sha:
project
.
commit
.
sha
,
ref:
'master'
)
ref:
'master'
)
end
end
...
...
spec/features/security/project/public_access_spec.rb
View file @
20c7144e
...
@@ -142,8 +142,8 @@ describe "Public Project Access", feature: true do
...
@@ -142,8 +142,8 @@ describe "Public Project Access", feature: true do
end
end
describe
"GET /:project_path/builds/:id"
do
describe
"GET /:project_path/builds/:id"
do
let
(
:
commit
)
{
create
(
:ci_commit
,
project:
project
)
}
let
(
:
pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
commit
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
subject
{
namespace_project_build_path
(
project
.
namespace
,
project
,
build
.
id
)
}
subject
{
namespace_project_build_path
(
project
.
namespace
,
project
,
build
.
id
)
}
context
"when allowed for public"
do
context
"when allowed for public"
do
...
...
spec/lib/ci/charts_spec.rb
View file @
20c7144e
...
@@ -4,19 +4,19 @@ describe Ci::Charts, lib: true do
...
@@ -4,19 +4,19 @@ describe Ci::Charts, lib: true do
context
"build_times"
do
context
"build_times"
do
before
do
before
do
@
commit
=
FactoryGirl
.
create
(
:ci_commit
)
@
pipeline
=
FactoryGirl
.
create
(
:ci_pipeline
)
FactoryGirl
.
create
(
:ci_build
,
pipeline:
@
commit
)
FactoryGirl
.
create
(
:ci_build
,
pipeline:
@
pipeline
)
end
end
it
'should return build times in minutes'
do
it
'should return build times in minutes'
do
chart
=
Ci
::
Charts
::
BuildTime
.
new
(
@
commit
.
project
)
chart
=
Ci
::
Charts
::
BuildTime
.
new
(
@
pipeline
.
project
)
expect
(
chart
.
build_times
).
to
eq
([
2
])
expect
(
chart
.
build_times
).
to
eq
([
2
])
end
end
it
'should handle nil build times'
do
it
'should handle nil build times'
do
create
(
:ci_
commit
,
duration:
nil
,
project:
@commit
.
project
)
create
(
:ci_
pipeline
,
duration:
nil
,
project:
@pipeline
.
project
)
chart
=
Ci
::
Charts
::
BuildTime
.
new
(
@
commit
.
project
)
chart
=
Ci
::
Charts
::
BuildTime
.
new
(
@
pipeline
.
project
)
expect
(
chart
.
build_times
).
to
eq
([
2
,
0
])
expect
(
chart
.
build_times
).
to
eq
([
2
,
0
])
end
end
end
end
...
...
spec/lib/gitlab/badge/build_spec.rb
View file @
20c7144e
...
@@ -42,9 +42,8 @@ describe Gitlab::Badge::Build do
...
@@ -42,9 +42,8 @@ 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
,
ref:
branch
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
sha:
sha
,
ref:
branch
)
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
ci_commit
)
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
context
'build success'
do
context
'build success'
do
before
{
build
.
success!
}
before
{
build
.
success!
}
...
...
spec/models/build_spec.rb
View file @
20c7144e
...
@@ -2,16 +2,16 @@ require 'spec_helper'
...
@@ -2,16 +2,16 @@ require 'spec_helper'
describe
Ci
::
Build
,
models:
true
do
describe
Ci
::
Build
,
models:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:
commit
)
{
create
(
:ci_commit
,
project:
project
)
}
let
(
:
pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
commit
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
it
{
is_expected
.
to
validate_presence_of
:ref
}
it
{
is_expected
.
to
validate_presence_of
:ref
}
it
{
is_expected
.
to
respond_to
:trace_html
}
it
{
is_expected
.
to
respond_to
:trace_html
}
describe
'#first_pending'
do
describe
'#first_pending'
do
let!
(
:first
)
{
create
(
:ci_build
,
pipeline:
commit
,
status:
'pending'
,
created_at:
Date
.
yesterday
)
}
let!
(
:first
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
status:
'pending'
,
created_at:
Date
.
yesterday
)
}
let!
(
:second
)
{
create
(
:ci_build
,
pipeline:
commit
,
status:
'pending'
)
}
let!
(
:second
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
status:
'pending'
)
}
subject
{
Ci
::
Build
.
first_pending
}
subject
{
Ci
::
Build
.
first_pending
}
it
{
is_expected
.
to
be_a
(
Ci
::
Build
)
}
it
{
is_expected
.
to
be_a
(
Ci
::
Build
)
}
...
@@ -97,7 +97,7 @@ describe Ci::Build, models: true do
...
@@ -97,7 +97,7 @@ describe Ci::Build, models: true do
# describe :timeout do
# describe :timeout do
# subject { build.timeout }
# subject { build.timeout }
#
#
# it { is_expected.to eq(
commit
.project.timeout) }
# it { is_expected.to eq(
pipeline
.project.timeout) }
# end
# end
describe
'#options'
do
describe
'#options'
do
...
@@ -124,13 +124,13 @@ describe Ci::Build, models: true do
...
@@ -124,13 +124,13 @@ describe Ci::Build, models: true do
describe
'#project'
do
describe
'#project'
do
subject
{
build
.
project
}
subject
{
build
.
project
}
it
{
is_expected
.
to
eq
(
commit
.
project
)
}
it
{
is_expected
.
to
eq
(
pipeline
.
project
)
}
end
end
describe
'#project_id'
do
describe
'#project_id'
do
subject
{
build
.
project_id
}
subject
{
build
.
project_id
}
it
{
is_expected
.
to
eq
(
commit
.
project_id
)
}
it
{
is_expected
.
to
eq
(
pipeline
.
project_id
)
}
end
end
describe
'#project_name'
do
describe
'#project_name'
do
...
@@ -219,7 +219,7 @@ describe Ci::Build, models: true do
...
@@ -219,7 +219,7 @@ describe Ci::Build, models: true do
context
'and trigger variables'
do
context
'and trigger variables'
do
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
,
commit:
commit
,
trigger:
trigger
)
}
let
(
:trigger_request
)
{
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
,
trigger:
trigger
)
}
let
(
:trigger_variables
)
do
let
(
:trigger_variables
)
do
[
[
{
key: :TRIGGER_KEY
,
value:
'TRIGGER_VALUE'
,
public:
false
}
{
key: :TRIGGER_KEY
,
value:
'TRIGGER_VALUE'
,
public:
false
}
...
@@ -428,10 +428,10 @@ describe Ci::Build, models: true do
...
@@ -428,10 +428,10 @@ describe Ci::Build, models: true do
end
end
describe
'#depends_on_builds'
do
describe
'#depends_on_builds'
do
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
commit
,
name:
'build'
,
stage_idx:
0
,
stage:
'build'
)
}
let!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'build'
,
stage_idx:
0
,
stage:
'build'
)
}
let!
(
:rspec_test
)
{
create
(
:ci_build
,
pipeline:
commit
,
name:
'rspec'
,
stage_idx:
1
,
stage:
'test'
)
}
let!
(
:rspec_test
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'rspec'
,
stage_idx:
1
,
stage:
'test'
)
}
let!
(
:rubocop_test
)
{
create
(
:ci_build
,
pipeline:
commit
,
name:
'rubocop'
,
stage_idx:
1
,
stage:
'test'
)
}
let!
(
:rubocop_test
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'rubocop'
,
stage_idx:
1
,
stage:
'test'
)
}
let!
(
:staging
)
{
create
(
:ci_build
,
pipeline:
commit
,
name:
'staging'
,
stage_idx:
2
,
stage:
'deploy'
)
}
let!
(
:staging
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
name:
'staging'
,
stage_idx:
2
,
stage:
'deploy'
)
}
it
'to have no dependents if this is first build'
do
it
'to have no dependents if this is first build'
do
expect
(
build
.
depends_on_builds
).
to
be_empty
expect
(
build
.
depends_on_builds
).
to
be_empty
...
@@ -451,19 +451,19 @@ describe Ci::Build, models: true do
...
@@ -451,19 +451,19 @@ describe Ci::Build, models: true do
end
end
end
end
def
create_mr
(
build
,
commit
,
factory: :merge_request
,
created_at:
Time
.
now
)
def
create_mr
(
build
,
pipeline
,
factory: :merge_request
,
created_at:
Time
.
now
)
create
(
factory
,
source_project_id:
commit
.
gl_project_id
,
create
(
factory
,
source_project_id:
pipeline
.
gl_project_id
,
target_project_id:
commit
.
gl_project_id
,
target_project_id:
pipeline
.
gl_project_id
,
source_branch:
build
.
ref
,
source_branch:
build
.
ref
,
created_at:
created_at
)
created_at:
created_at
)
end
end
describe
'#merge_request'
do
describe
'#merge_request'
do
context
'when a MR has a reference to the
commit
'
do
context
'when a MR has a reference to the
pipeline
'
do
before
do
before
do
@merge_request
=
create_mr
(
build
,
commit
,
factory: :merge_request
)
@merge_request
=
create_mr
(
build
,
pipeline
,
factory: :merge_request
)
commits
=
[
double
(
id:
commit
.
sha
)]
commits
=
[
double
(
id:
pipeline
.
sha
)]
allow
(
@merge_request
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
@merge_request
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
MergeRequest
).
to
receive_message_chain
(
:includes
,
:where
,
:reorder
).
and_return
([
@merge_request
])
allow
(
MergeRequest
).
to
receive_message_chain
(
:includes
,
:where
,
:reorder
).
and_return
([
@merge_request
])
end
end
...
@@ -473,19 +473,19 @@ describe Ci::Build, models: true do
...
@@ -473,19 +473,19 @@ describe Ci::Build, models: true do
end
end
end
end
context
'when there is not a MR referencing the
commit
'
do
context
'when there is not a MR referencing the
pipeline
'
do
it
'returns nil'
do
it
'returns nil'
do
expect
(
build
.
merge_request
).
to
be_nil
expect
(
build
.
merge_request
).
to
be_nil
end
end
end
end
context
'when more than one MR have a reference to the
commit
'
do
context
'when more than one MR have a reference to the
pipeline
'
do
before
do
before
do
@merge_request
=
create_mr
(
build
,
commit
,
factory: :merge_request
)
@merge_request
=
create_mr
(
build
,
pipeline
,
factory: :merge_request
)
@merge_request
.
close!
@merge_request
.
close!
@merge_request2
=
create_mr
(
build
,
commit
,
factory: :merge_request
)
@merge_request2
=
create_mr
(
build
,
pipeline
,
factory: :merge_request
)
commits
=
[
double
(
id:
commit
.
sha
)]
commits
=
[
double
(
id:
pipeline
.
sha
)]
allow
(
@merge_request
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
@merge_request
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
@merge_request2
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
@merge_request2
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
MergeRequest
).
to
receive_message_chain
(
:includes
,
:where
,
:reorder
).
and_return
([
@merge_request
,
@merge_request2
])
allow
(
MergeRequest
).
to
receive_message_chain
(
:includes
,
:where
,
:reorder
).
and_return
([
@merge_request
,
@merge_request2
])
...
@@ -498,11 +498,11 @@ describe Ci::Build, models: true do
...
@@ -498,11 +498,11 @@ describe Ci::Build, models: true do
context
'when a Build is created after the MR'
do
context
'when a Build is created after the MR'
do
before
do
before
do
@merge_request
=
create_mr
(
build
,
commit
,
factory: :merge_request_with_diffs
)
@merge_request
=
create_mr
(
build
,
pipeline
,
factory: :merge_request_with_diffs
)
commit2
=
create
(
:ci_commit
,
project:
project
)
pipeline2
=
create
(
:ci_pipeline
,
project:
project
)
@build2
=
create
(
:ci_build
,
pipeline:
commit
2
)
@build2
=
create
(
:ci_build
,
pipeline:
pipeline
2
)
commits
=
[
double
(
id:
commit
.
sha
),
double
(
id:
commit
2
.
sha
)]
commits
=
[
double
(
id:
pipeline
.
sha
),
double
(
id:
pipeline
2
.
sha
)]
allow
(
@merge_request
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
@merge_request
).
to
receive
(
:commits
).
and_return
(
commits
)
allow
(
MergeRequest
).
to
receive_message_chain
(
:includes
,
:where
,
:reorder
).
and_return
([
@merge_request
])
allow
(
MergeRequest
).
to
receive_message_chain
(
:includes
,
:where
,
:reorder
).
and_return
([
@merge_request
])
end
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
20c7144e
This diff is collapsed.
Click to expand it.
spec/models/commit_status_spec.rb
View file @
20c7144e
require
'spec_helper'
require
'spec_helper'
describe
CommitStatus
,
models:
true
do
describe
CommitStatus
,
models:
true
do
let
(
:
commit
)
{
FactoryGirl
.
create
:ci_commit
}
let
(
:
pipeline
)
{
FactoryGirl
.
create
:ci_pipeline
}
let
(
:commit_status
)
{
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
}
let
(
:commit_status
)
{
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
}
it
{
is_expected
.
to
belong_to
(
:pipeline
)
}
it
{
is_expected
.
to
belong_to
(
:pipeline
)
}
it
{
is_expected
.
to
belong_to
(
:user
)
}
it
{
is_expected
.
to
belong_to
(
:user
)
}
...
@@ -121,11 +121,11 @@ describe CommitStatus, models: true do
...
@@ -121,11 +121,11 @@ describe CommitStatus, models: true do
subject
{
CommitStatus
.
latest
.
order
(
:id
)
}
subject
{
CommitStatus
.
latest
.
order
(
:id
)
}
before
do
before
do
@commit1
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'aa'
,
ref:
'bb'
,
status:
'running'
@commit1
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
'bb'
,
status:
'running'
@commit2
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'cc'
,
ref:
'cc'
,
status:
'pending'
@commit2
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'cc'
,
ref:
'cc'
,
status:
'pending'
@commit3
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'aa'
,
ref:
'cc'
,
status:
'success'
@commit3
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
'cc'
,
status:
'success'
@commit4
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'cc'
,
ref:
'bb'
,
status:
'success'
@commit4
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'cc'
,
ref:
'bb'
,
status:
'success'
@commit5
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'aa'
,
ref:
'bb'
,
status:
'success'
@commit5
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
'bb'
,
status:
'success'
end
end
it
'return unique statuses'
do
it
'return unique statuses'
do
...
@@ -137,11 +137,11 @@ describe CommitStatus, models: true do
...
@@ -137,11 +137,11 @@ describe CommitStatus, models: true do
subject
{
CommitStatus
.
running_or_pending
.
order
(
:id
)
}
subject
{
CommitStatus
.
running_or_pending
.
order
(
:id
)
}
before
do
before
do
@commit1
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'aa'
,
ref:
'bb'
,
status:
'running'
@commit1
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
'bb'
,
status:
'running'
@commit2
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'cc'
,
ref:
'cc'
,
status:
'pending'
@commit2
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'cc'
,
ref:
'cc'
,
status:
'pending'
@commit3
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'aa'
,
ref:
nil
,
status:
'success'
@commit3
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'aa'
,
ref:
nil
,
status:
'success'
@commit4
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'dd'
,
ref:
nil
,
status:
'failed'
@commit4
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'dd'
,
ref:
nil
,
status:
'failed'
@commit5
=
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
name:
'ee'
,
ref:
nil
,
status:
'canceled'
@commit5
=
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
name:
'ee'
,
ref:
nil
,
status:
'canceled'
end
end
it
'return statuses that are running or pending'
do
it
'return statuses that are running or pending'
do
...
@@ -152,17 +152,17 @@ describe CommitStatus, models: true do
...
@@ -152,17 +152,17 @@ describe CommitStatus, models: true do
describe
'#before_sha'
do
describe
'#before_sha'
do
subject
{
commit_status
.
before_sha
}
subject
{
commit_status
.
before_sha
}
context
'when no before_sha is set for
ci::commit
'
do
context
'when no before_sha is set for
pipeline
'
do
before
{
commit
.
before_sha
=
nil
}
before
{
pipeline
.
before_sha
=
nil
}
it
'return blank sha'
do
it
'return blank sha'
do
is_expected
.
to
eq
(
Gitlab
::
Git
::
BLANK_SHA
)
is_expected
.
to
eq
(
Gitlab
::
Git
::
BLANK_SHA
)
end
end
end
end
context
'for before_sha set for
ci::commit
'
do
context
'for before_sha set for
pipeline
'
do
let
(
:value
)
{
'1234'
}
let
(
:value
)
{
'1234'
}
before
{
commit
.
before_sha
=
value
}
before
{
pipeline
.
before_sha
=
value
}
it
'return the set value'
do
it
'return the set value'
do
is_expected
.
to
eq
(
value
)
is_expected
.
to
eq
(
value
)
...
@@ -172,14 +172,14 @@ describe CommitStatus, models: true do
...
@@ -172,14 +172,14 @@ describe CommitStatus, models: true do
describe
'#stages'
do
describe
'#stages'
do
before
do
before
do
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
stage:
'build'
,
stage_idx:
0
,
status:
'success'
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
stage_idx:
0
,
status:
'success'
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
stage:
'build'
,
stage_idx:
0
,
status:
'failed'
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
stage:
'build'
,
stage_idx:
0
,
status:
'failed'
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
stage:
'deploy'
,
stage_idx:
2
,
status:
'running'
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
stage:
'deploy'
,
stage_idx:
2
,
status:
'running'
FactoryGirl
.
create
:commit_status
,
pipeline:
commit
,
stage:
'test'
,
stage_idx:
1
,
status:
'success'
FactoryGirl
.
create
:commit_status
,
pipeline:
pipeline
,
stage:
'test'
,
stage_idx:
1
,
status:
'success'
end
end
context
'stages list'
do
context
'stages list'
do
subject
{
CommitStatus
.
where
(
pipeline:
commit
).
stages
}
subject
{
CommitStatus
.
where
(
pipeline:
pipeline
).
stages
}
it
'return ordered list of stages'
do
it
'return ordered list of stages'
do
is_expected
.
to
eq
(
%w(build test deploy)
)
is_expected
.
to
eq
(
%w(build test deploy)
)
...
@@ -187,7 +187,7 @@ describe CommitStatus, models: true do
...
@@ -187,7 +187,7 @@ describe CommitStatus, models: true do
end
end
context
'stages with statuses'
do
context
'stages with statuses'
do
subject
{
CommitStatus
.
where
(
pipeline:
commit
).
stages_status
}
subject
{
CommitStatus
.
where
(
pipeline:
pipeline
).
stages_status
}
it
'return list of stages with statuses'
do
it
'return list of stages with statuses'
do
is_expected
.
to
eq
({
is_expected
.
to
eq
({
...
...
spec/models/generic_commit_status_spec.rb
View file @
20c7144e
require
'spec_helper'
require
'spec_helper'
describe
GenericCommitStatus
,
models:
true
do
describe
GenericCommitStatus
,
models:
true
do
let
(
:
commit
)
{
FactoryGirl
.
create
:ci_commit
}
let
(
:
pipeline
)
{
FactoryGirl
.
create
:ci_pipeline
}
let
(
:generic_commit_status
)
{
FactoryGirl
.
create
:generic_commit_status
,
pipeline:
commit
}
let
(
:generic_commit_status
)
{
FactoryGirl
.
create
:generic_commit_status
,
pipeline:
pipeline
}
describe
:context
do
describe
:context
do
subject
{
generic_commit_status
.
context
}
subject
{
generic_commit_status
.
context
}
...
...
spec/models/merge_request_spec.rb
View file @
20c7144e
...
@@ -394,7 +394,7 @@ describe MergeRequest, models: true do
...
@@ -394,7 +394,7 @@ 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'
)
pipeline
=
double
(
:ci_
commit
,
ref:
'master'
)
pipeline
=
double
(
:ci_
pipeline
,
ref:
'master'
)
allow
(
subject
).
to
receive
(
:last_commit
).
and_return
(
commit
)
allow
(
subject
).
to
receive
(
:last_commit
).
and_return
(
commit
)
...
...
spec/models/project_spec.rb
View file @
20c7144e
...
@@ -399,23 +399,23 @@ describe Project, models: true do
...
@@ -399,23 +399,23 @@ describe Project, models: true do
end
end
end
end
describe
:
ci_commit
do
describe
:
pipeline
do
let
(
:project
)
{
create
:project
}
let
(
:project
)
{
create
:project
}
let
(
:
commit
)
{
create
:ci_commit
,
project:
project
,
ref:
'master'
}
let
(
:
pipeline
)
{
create
:pipeline
,
project:
project
,
ref:
'master'
}
subject
{
project
.
pipeline
(
commit
.
sha
,
'master'
)
}
subject
{
project
.
pipeline
(
pipeline
.
sha
,
'master'
)
}
it
{
is_expected
.
to
eq
(
commit
)
}
it
{
is_expected
.
to
eq
(
pipeline
)
}
context
'return latest'
do
context
'return latest'
do
let
(
:
commit2
)
{
create
:ci_commit
,
project:
project
,
ref:
'master'
}
let
(
:
pipeline2
)
{
create
:pipeline
,
project:
project
,
ref:
'master'
}
before
do
before
do
commit
pipeline
commit
2
pipeline
2
end
end
it
{
is_expected
.
to
eq
(
commit
2
)
}
it
{
is_expected
.
to
eq
(
pipeline
2
)
}
end
end
end
end
...
...
spec/requests/api/builds_spec.rb
View file @
20c7144e
...
@@ -9,8 +9,8 @@ describe API::API, api: true do
...
@@ -9,8 +9,8 @@ describe API::API, api: true do
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:project
)
{
create
(
:project
,
creator_id:
user
.
id
)
}
let!
(
:developer
)
{
create
(
:project_member
,
:developer
,
user:
user
,
project:
project
)
}
let!
(
:developer
)
{
create
(
:project_member
,
:developer
,
user:
user
,
project:
project
)
}
let!
(
:reporter
)
{
create
(
:project_member
,
:reporter
,
user:
user2
,
project:
project
)
}
let!
(
:reporter
)
{
create
(
:project_member
,
:reporter
,
user:
user2
,
project:
project
)
}
let
(
:
commit
)
{
create
(
:ci_commit
,
project:
project
)}
let
(
:
pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
commit
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
describe
'GET /projects/:id/builds '
do
describe
'GET /projects/:id/builds '
do
let
(
:query
)
{
''
}
let
(
:query
)
{
''
}
...
@@ -59,8 +59,8 @@ describe API::API, api: true do
...
@@ -59,8 +59,8 @@ 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_pipeline
(
commit
.
sha
,
'master'
)
project
.
ensure_pipeline
(
pipeline
.
sha
,
'master'
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
commit
.
sha
}
/builds"
,
api_user
)
get
api
(
"/projects/
#{
project
.
id
}
/repository/commits/
#{
pipeline
.
sha
}
/builds"
,
api_user
)
end
end
context
'authorized user'
do
context
'authorized user'
do
...
@@ -102,7 +102,7 @@ describe API::API, api: true do
...
@@ -102,7 +102,7 @@ describe API::API, api: true do
before
{
get
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/artifacts"
,
api_user
)
}
before
{
get
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/artifacts"
,
api_user
)
}
context
'build with artifacts'
do
context
'build with artifacts'
do
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
commit
)
}
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
context
'authorized user'
do
context
'authorized user'
do
let
(
:download_headers
)
do
let
(
:download_headers
)
do
...
@@ -131,7 +131,7 @@ describe API::API, api: true do
...
@@ -131,7 +131,7 @@ describe API::API, api: true do
end
end
describe
'GET /projects/:id/builds/:build_id/trace'
do
describe
'GET /projects/:id/builds/:build_id/trace'
do
let
(
:build
)
{
create
(
:ci_build
,
:trace
,
pipeline:
commit
)
}
let
(
:build
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
)
}
before
{
get
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/trace"
,
api_user
)
}
before
{
get
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/trace"
,
api_user
)
}
...
@@ -181,7 +181,7 @@ describe API::API, api: true do
...
@@ -181,7 +181,7 @@ describe API::API, api: true do
end
end
describe
'POST /projects/:id/builds/:build_id/retry'
do
describe
'POST /projects/:id/builds/:build_id/retry'
do
let
(
:build
)
{
create
(
:ci_build
,
:canceled
,
pipeline:
commit
)
}
let
(
:build
)
{
create
(
:ci_build
,
:canceled
,
pipeline:
pipeline
)
}
before
{
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/retry"
,
api_user
)
}
before
{
post
api
(
"/projects/
#{
project
.
id
}
/builds/
#{
build
.
id
}
/retry"
,
api_user
)
}
...
@@ -218,7 +218,7 @@ describe API::API, api: true do
...
@@ -218,7 +218,7 @@ describe API::API, api: true do
end
end
context
'build is erasable'
do
context
'build is erasable'
do
let
(
:build
)
{
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
project:
project
,
pipeline:
commit
)
}
let
(
:build
)
{
create
(
:ci_build
,
:trace
,
:artifacts
,
:success
,
project:
project
,
pipeline:
pipeline
)
}
it
'should erase build content'
do
it
'should erase build content'
do
expect
(
response
.
status
).
to
eq
201
expect
(
response
.
status
).
to
eq
201
...
@@ -234,7 +234,7 @@ describe API::API, api: true do
...
@@ -234,7 +234,7 @@ describe API::API, api: true do
end
end
context
'build is not erasable'
do
context
'build is not erasable'
do
let
(
:build
)
{
create
(
:ci_build
,
:trace
,
project:
project
,
pipeline:
commit
)
}
let
(
:build
)
{
create
(
:ci_build
,
:trace
,
project:
project
,
pipeline:
pipeline
)
}
it
'should respond with forbidden'
do
it
'should respond with forbidden'
do
expect
(
response
.
status
).
to
eq
403
expect
(
response
.
status
).
to
eq
403
...
...
spec/requests/api/merge_requests_spec.rb
View file @
20c7144e
...
@@ -388,7 +388,7 @@ describe API::API, api: true do
...
@@ -388,7 +388,7 @@ describe API::API, api: true do
end
end
describe
"PUT /projects/:id/merge_requests/:merge_request_id/merge"
do
describe
"PUT /projects/:id/merge_requests/:merge_request_id/merge"
do
let
(
:pipeline
)
{
create
(
:ci_
commit
_without_jobs
)
}
let
(
:pipeline
)
{
create
(
:ci_
pipeline
_without_jobs
)
}
it
"should return merge_request in case of success"
do
it
"should return merge_request in case of success"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
)
...
@@ -443,7 +443,7 @@ describe API::API, api: true do
...
@@ -443,7 +443,7 @@ describe API::API, api: true do
it
"enables merge when build succeeds if the ci is active"
do
it
"enables merge when build succeeds if the ci is active"
do
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:pipeline
).
and_return
(
pipeline
)
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:pipeline
).
and_return
(
pipeline
)
allow
(
ci_commit
).
to
receive
(
:active?
).
and_return
(
true
)
allow
(
pipeline
).
to
receive
(
:active?
).
and_return
(
true
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
),
merge_when_build_succeeds:
true
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
),
merge_when_build_succeeds:
true
...
...
spec/requests/api/triggers_spec.rb
View file @
20c7144e
...
@@ -23,7 +23,7 @@ describe API::API do
...
@@ -23,7 +23,7 @@ describe API::API do
end
end
before
do
before
do
stub_ci_
commit
_to_return_yaml_file
stub_ci_
pipeline
_to_return_yaml_file
end
end
context
'Handles errors'
do
context
'Handles errors'
do
...
@@ -44,13 +44,13 @@ describe API::API do
...
@@ -44,13 +44,13 @@ describe API::API do
end
end
context
'Have a commit'
do
context
'Have a commit'
do
let
(
:
commit
)
{
project
.
pipelines
.
last
}
let
(
:
pipeline
)
{
project
.
pipelines
.
last
}
it
'should create builds'
do
it
'should create builds'
do
post
api
(
"/projects/
#{
project
.
id
}
/trigger/builds"
),
options
.
merge
(
ref:
'master'
)
post
api
(
"/projects/
#{
project
.
id
}
/trigger/builds"
),
options
.
merge
(
ref:
'master'
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
commit
.
builds
.
reload
pipeline
.
builds
.
reload
expect
(
commit
.
builds
.
size
).
to
eq
(
2
)
expect
(
pipeline
.
builds
.
size
).
to
eq
(
2
)
end
end
it
'should return bad request with no builds created if there\'s no commit for that ref'
do
it
'should return bad request with no builds created if there\'s no commit for that ref'
do
...
@@ -79,8 +79,8 @@ describe API::API do
...
@@ -79,8 +79,8 @@ describe API::API do
it
'create trigger request with variables'
do
it
'create trigger request with variables'
do
post
api
(
"/projects/
#{
project
.
id
}
/trigger/builds"
),
options
.
merge
(
variables:
variables
,
ref:
'master'
)
post
api
(
"/projects/
#{
project
.
id
}
/trigger/builds"
),
options
.
merge
(
variables:
variables
,
ref:
'master'
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
commit
.
builds
.
reload
pipeline
.
builds
.
reload
expect
(
commit
.
builds
.
first
.
trigger_request
.
variables
).
to
eq
(
variables
)
expect
(
pipeline
.
builds
.
first
.
trigger_request
.
variables
).
to
eq
(
variables
)
end
end
end
end
end
end
...
...
spec/requests/ci/api/builds_spec.rb
View file @
20c7144e
...
@@ -7,7 +7,7 @@ describe Ci::API::API do
...
@@ -7,7 +7,7 @@ describe Ci::API::API do
let
(
:project
)
{
FactoryGirl
.
create
(
:empty_project
)
}
let
(
:project
)
{
FactoryGirl
.
create
(
:empty_project
)
}
before
do
before
do
stub_ci_
commit
_to_return_yaml_file
stub_ci_
pipeline
_to_return_yaml_file
end
end
describe
"Builds API for runners"
do
describe
"Builds API for runners"
do
...
@@ -20,9 +20,9 @@ describe Ci::API::API do
...
@@ -20,9 +20,9 @@ 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
,
ref:
'master'
)
pipeline
=
FactoryGirl
.
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
nil
)
pipeline
.
create_builds
(
nil
)
build
=
commit
.
builds
.
first
build
=
pipeline
.
builds
.
first
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
@@ -38,8 +38,8 @@ describe Ci::API::API do
...
@@ -38,8 +38,8 @@ describe Ci::API::API do
end
end
it
"should return 404 error if no builds for specific runner"
do
it
"should return 404 error if no builds for specific runner"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
shared_project
)
pipeline
=
FactoryGirl
.
create
(
:ci_pipeline
,
project:
shared_project
)
FactoryGirl
.
create
(
:ci_build
,
pipeline:
commit
,
status:
'pending'
)
FactoryGirl
.
create
(
:ci_build
,
pipeline:
pipeline
,
status:
'pending'
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
...
@@ -47,8 +47,8 @@ describe Ci::API::API do
...
@@ -47,8 +47,8 @@ describe Ci::API::API do
end
end
it
"should return 404 error if no builds for shared runner"
do
it
"should return 404 error if no builds for shared runner"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
pipeline
=
FactoryGirl
.
create
(
:ci_pipeline
,
project:
project
)
FactoryGirl
.
create
(
:ci_build
,
pipeline:
commit
,
status:
'pending'
)
FactoryGirl
.
create
(
:ci_build
,
pipeline:
pipeline
,
status:
'pending'
)
post
ci_api
(
"/builds/register"
),
token:
shared_runner
.
token
post
ci_api
(
"/builds/register"
),
token:
shared_runner
.
token
...
@@ -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
,
ref:
'master'
)
pipeline
=
FactoryGirl
.
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
nil
)
pipeline
.
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
,
ref:
'master'
)
pipeline
=
FactoryGirl
.
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
nil
)
pipeline
.
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
,
ref:
'master'
)
pipeline
=
FactoryGirl
.
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
)
trigger_request
=
FactoryGirl
.
create
(
:ci_trigger_request_with_variables
,
pipeline:
commit
,
trigger:
trigger
)
trigger_request
=
FactoryGirl
.
create
(
:ci_trigger_request_with_variables
,
pipeline:
pipeline
,
trigger:
trigger
)
commit
.
create_builds
(
nil
,
trigger_request
)
pipeline
.
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,9 +103,9 @@ describe Ci::API::API do
...
@@ -103,9 +103,9 @@ describe Ci::API::API do
end
end
it
"returns dependent builds"
do
it
"returns dependent builds"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
pipeline
=
FactoryGirl
.
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
)
commit
.
create_builds
(
nil
,
nil
)
pipeline
.
create_builds
(
nil
,
nil
)
commit
.
builds
.
where
(
stage:
'test'
).
each
(
&
:success
)
pipeline
.
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
}
...
@@ -131,8 +131,8 @@ describe Ci::API::API do
...
@@ -131,8 +131,8 @@ describe Ci::API::API do
context
'when build has no tags'
do
context
'when build has no tags'
do
before
do
before
do
commit
=
create
(
:ci_commit
,
project:
project
)
pipeline
=
create
(
:ci_pipeline
,
project:
project
)
create
(
:ci_build
,
pipeline:
commit
,
tags:
[])
create
(
:ci_build
,
pipeline:
pipeline
,
tags:
[])
end
end
context
'when runner is allowed to pick untagged builds'
do
context
'when runner is allowed to pick untagged builds'
do
...
@@ -163,8 +163,8 @@ describe Ci::API::API do
...
@@ -163,8 +163,8 @@ describe Ci::API::API do
end
end
describe
"PUT /builds/:id"
do
describe
"PUT /builds/:id"
do
let
(
:
commit
)
{
create
(
:ci_commit
,
project:
project
)}
let
(
:
pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)}
let
(
:build
)
{
create
(
:ci_build
,
:trace
,
pipeline:
commit
,
runner_id:
runner
.
id
)
}
let
(
:build
)
{
create
(
:ci_build
,
:trace
,
pipeline:
pipeline
,
runner_id:
runner
.
id
)
}
before
do
before
do
build
.
run!
build
.
run!
...
@@ -237,8 +237,8 @@ describe Ci::API::API do
...
@@ -237,8 +237,8 @@ describe Ci::API::API do
context
"Artifacts"
do
context
"Artifacts"
do
let
(
:file_upload
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:file_upload
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:file_upload2
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/gif'
)
}
let
(
:file_upload2
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/gif'
)
}
let
(
:
commit
)
{
create
(
:ci_commit
,
project:
project
)
}
let
(
:
pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
commit
,
runner_id:
runner
.
id
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
,
runner_id:
runner
.
id
)
}
let
(
:authorize_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts/authorize"
)
}
let
(
:authorize_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts/authorize"
)
}
let
(
:post_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts"
)
}
let
(
:post_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts"
)
}
let
(
:delete_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts"
)
}
let
(
:delete_url
)
{
ci_api
(
"/builds/
#{
build
.
id
}
/artifacts"
)
}
...
...
spec/requests/ci/api/triggers_spec.rb
View file @
20c7144e
...
@@ -15,7 +15,7 @@ describe Ci::API::API do
...
@@ -15,7 +15,7 @@ describe Ci::API::API do
end
end
before
do
before
do
stub_ci_
commit
_to_return_yaml_file
stub_ci_
pipeline
_to_return_yaml_file
end
end
context
'Handles errors'
do
context
'Handles errors'
do
...
@@ -36,13 +36,13 @@ describe Ci::API::API do
...
@@ -36,13 +36,13 @@ describe Ci::API::API do
end
end
context
'Have a commit'
do
context
'Have a commit'
do
let
(
:
commit
)
{
project
.
pipelines
.
last
}
let
(
:
pipeline
)
{
project
.
pipelines
.
last
}
it
'should create builds'
do
it
'should create builds'
do
post
ci_api
(
"/projects/
#{
project
.
ci_id
}
/refs/master/trigger"
),
options
post
ci_api
(
"/projects/
#{
project
.
ci_id
}
/refs/master/trigger"
),
options
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
commit
.
builds
.
reload
pipeline
.
builds
.
reload
expect
(
commit
.
builds
.
size
).
to
eq
(
2
)
expect
(
pipeline
.
builds
.
size
).
to
eq
(
2
)
end
end
it
'should return bad request with no builds created if there\'s no commit for that ref'
do
it
'should return bad request with no builds created if there\'s no commit for that ref'
do
...
@@ -71,8 +71,8 @@ describe Ci::API::API do
...
@@ -71,8 +71,8 @@ describe Ci::API::API do
it
'create trigger request with variables'
do
it
'create trigger request with variables'
do
post
ci_api
(
"/projects/
#{
project
.
ci_id
}
/refs/master/trigger"
),
options
.
merge
(
variables:
variables
)
post
ci_api
(
"/projects/
#{
project
.
ci_id
}
/refs/master/trigger"
),
options
.
merge
(
variables:
variables
)
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
response
.
status
).
to
eq
(
201
)
commit
.
builds
.
reload
pipeline
.
builds
.
reload
expect
(
commit
.
builds
.
first
.
trigger_request
.
variables
).
to
eq
(
variables
)
expect
(
pipeline
.
builds
.
first
.
trigger_request
.
variables
).
to
eq
(
variables
)
end
end
end
end
end
end
...
...
spec/services/ci/create_builds_service_spec.rb
View file @
20c7144e
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
CreateBuildsService
,
services:
true
do
describe
Ci
::
CreateBuildsService
,
services:
true
do
let
(
:
commit
)
{
create
(
:ci_commit
,
ref:
'master'
)
}
let
(
:
pipeline
)
{
create
(
:ci_pipeline
,
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
(
commit
).
execute
(
commit
,
nil
,
user
,
status
)
described_class
.
new
(
pipeline
).
execute
(
'test'
,
nil
,
user
,
status
)
end
end
context
'next builds available'
do
context
'next builds available'
do
...
...
spec/services/ci/create_trigger_request_service_spec.rb
View file @
20c7144e
...
@@ -6,7 +6,7 @@ describe Ci::CreateTriggerRequestService, services: true do
...
@@ -6,7 +6,7 @@ describe Ci::CreateTriggerRequestService, services: true do
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
let
(
:trigger
)
{
create
(
:ci_trigger
,
project:
project
)
}
before
do
before
do
stub_ci_
commit
_to_return_yaml_file
stub_ci_
pipeline
_to_return_yaml_file
end
end
describe
:execute
do
describe
:execute
do
...
@@ -27,8 +27,8 @@ describe Ci::CreateTriggerRequestService, services: true do
...
@@ -27,8 +27,8 @@ describe Ci::CreateTriggerRequestService, services: true do
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
subject
{
service
.
execute
(
project
,
trigger
,
'master'
)
}
before
do
before
do
stub_ci_
commit
_yaml_file
(
'{}'
)
stub_ci_
pipeline
_yaml_file
(
'{}'
)
FactoryGirl
.
create
:ci_
commit
,
project:
project
FactoryGirl
.
create
:ci_
pipeline
,
project:
project
end
end
it
{
expect
(
subject
).
to
be_nil
}
it
{
expect
(
subject
).
to
be_nil
}
...
...
spec/services/ci/register_build_service_spec.rb
View file @
20c7144e
...
@@ -4,8 +4,8 @@ module Ci
...
@@ -4,8 +4,8 @@ module Ci
describe
RegisterBuildService
,
services:
true
do
describe
RegisterBuildService
,
services:
true
do
let!
(
:service
)
{
RegisterBuildService
.
new
}
let!
(
:service
)
{
RegisterBuildService
.
new
}
let!
(
:project
)
{
FactoryGirl
.
create
:empty_project
,
shared_runners_enabled:
false
}
let!
(
:project
)
{
FactoryGirl
.
create
:empty_project
,
shared_runners_enabled:
false
}
let!
(
:
commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
}
let!
(
:
pipeline
)
{
FactoryGirl
.
create
:ci_pipeline
,
project:
project
}
let!
(
:pending_build
)
{
FactoryGirl
.
create
:ci_build
,
pipeline:
commit
}
let!
(
:pending_build
)
{
FactoryGirl
.
create
:ci_build
,
pipeline:
pipeline
}
let!
(
:shared_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
true
)
}
let!
(
:shared_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
true
)
}
let!
(
:specific_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
false
)
}
let!
(
:specific_runner
)
{
FactoryGirl
.
create
(
:ci_runner
,
is_shared:
false
)
}
...
...
spec/services/create_commit_builds_service_spec.rb
View file @
20c7144e
...
@@ -6,12 +6,12 @@ describe CreateCommitBuildsService, services: true do
...
@@ -6,12 +6,12 @@ describe CreateCommitBuildsService, services: true do
let
(
:user
)
{
nil
}
let
(
:user
)
{
nil
}
before
do
before
do
stub_ci_
commit
_to_return_yaml_file
stub_ci_
pipeline
_to_return_yaml_file
end
end
describe
:execute
do
describe
:execute
do
context
'valid params'
do
context
'valid params'
do
let
(
:
commit
)
do
let
(
:
pipeline
)
do
service
.
execute
(
project
,
user
,
service
.
execute
(
project
,
user
,
ref:
'refs/heads/master'
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
before:
'00000000'
,
...
@@ -20,11 +20,11 @@ describe CreateCommitBuildsService, services: true do
...
@@ -20,11 +20,11 @@ describe CreateCommitBuildsService, services: true do
)
)
end
end
it
{
expect
(
commit
).
to
be_kind_of
(
Ci
::
Pipeline
)
}
it
{
expect
(
pipeline
).
to
be_kind_of
(
Ci
::
Pipeline
)
}
it
{
expect
(
commit
).
to
be_valid
}
it
{
expect
(
pipeline
).
to
be_valid
}
it
{
expect
(
commit
).
to
be_persisted
}
it
{
expect
(
pipeline
).
to
be_persisted
}
it
{
expect
(
commit
).
to
eq
(
project
.
pipelines
.
last
)
}
it
{
expect
(
pipeline
).
to
eq
(
project
.
pipelines
.
last
)
}
it
{
expect
(
commit
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
it
{
expect
(
pipeline
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
end
end
context
"skip tag if there is no build for it"
do
context
"skip tag if there is no build for it"
do
...
@@ -40,7 +40,7 @@ describe CreateCommitBuildsService, services: true do
...
@@ -40,7 +40,7 @@ describe CreateCommitBuildsService, services: true do
it
"creates commit if there is no appropriate job but deploy job has right ref setting"
do
it
"creates commit if there is no appropriate job but deploy job has right ref setting"
do
config
=
YAML
.
dump
({
deploy:
{
deploy:
"ls"
,
only:
[
"0_1"
]
}
})
config
=
YAML
.
dump
({
deploy:
{
deploy:
"ls"
,
only:
[
"0_1"
]
}
})
stub_ci_
commit
_yaml_file
(
config
)
stub_ci_
pipeline
_yaml_file
(
config
)
result
=
service
.
execute
(
project
,
user
,
result
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/0_1'
,
ref:
'refs/heads/0_1'
,
...
@@ -53,7 +53,7 @@ describe CreateCommitBuildsService, services: true do
...
@@ -53,7 +53,7 @@ describe CreateCommitBuildsService, services: true do
end
end
it
'skips creating ci_commit for refs without .gitlab-ci.yml'
do
it
'skips creating ci_commit for refs without .gitlab-ci.yml'
do
stub_ci_
commit
_yaml_file
(
nil
)
stub_ci_
pipeline
_yaml_file
(
nil
)
result
=
service
.
execute
(
project
,
user
,
result
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/0_1'
,
ref:
'refs/heads/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
...
@@ -67,18 +67,18 @@ describe CreateCommitBuildsService, services: true do
...
@@ -67,18 +67,18 @@ describe CreateCommitBuildsService, services: true do
it
'fails commits if yaml is invalid'
do
it
'fails commits if yaml is invalid'
do
message
=
'message'
message
=
'message'
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:git_commit_message
)
{
message
}
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:git_commit_message
)
{
message
}
stub_ci_
commit
_yaml_file
(
'invalid: file: file'
)
stub_ci_
pipeline
_yaml_file
(
'invalid: file: file'
)
commits
=
[{
message:
message
}]
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
pipeline
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
commits:
commits
)
)
expect
(
commit
).
to
be_persisted
expect
(
pipeline
).
to
be_persisted
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
pipeline
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
'failed'
)
expect
(
pipeline
.
status
).
to
eq
(
'failed'
)
expect
(
commit
.
yaml_errors
).
not_to
be_nil
expect
(
pipeline
.
yaml_errors
).
not_to
be_nil
end
end
describe
:ci_skip?
do
describe
:ci_skip?
do
...
@@ -90,45 +90,45 @@ describe CreateCommitBuildsService, services: true do
...
@@ -90,45 +90,45 @@ describe CreateCommitBuildsService, services: true do
it
"skips builds creation if there is [ci skip] tag in commit message"
do
it
"skips builds creation if there is [ci skip] tag in commit message"
do
commits
=
[{
message:
message
}]
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
pipeline
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
commits:
commits
)
)
expect
(
commit
).
to
be_persisted
expect
(
pipeline
).
to
be_persisted
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
pipeline
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
expect
(
pipeline
.
status
).
to
eq
(
"skipped"
)
end
end
it
"does not skips builds creation if there is no [ci skip] tag in commit message"
do
it
"does not skips builds creation if there is no [ci skip] tag in commit message"
do
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:git_commit_message
)
{
"some message"
}
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:git_commit_message
)
{
"some message"
}
commits
=
[{
message:
"some message"
}]
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
user
,
pipeline
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
commits:
commits
)
)
expect
(
commit
).
to
be_persisted
expect
(
pipeline
).
to
be_persisted
expect
(
commit
.
builds
.
first
.
name
).
to
eq
(
"staging"
)
expect
(
pipeline
.
builds
.
first
.
name
).
to
eq
(
"staging"
)
end
end
it
"skips builds creation if there is [ci skip] tag in commit message and yaml is invalid"
do
it
"skips builds creation if there is [ci skip] tag in commit message and yaml is invalid"
do
stub_ci_
commit
_yaml_file
(
'invalid: file: fiile'
)
stub_ci_
pipeline
_yaml_file
(
'invalid: file: fiile'
)
commits
=
[{
message:
message
}]
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
pipeline
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
commits:
commits
)
)
expect
(
commit
).
to
be_persisted
expect
(
pipeline
).
to
be_persisted
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
pipeline
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
expect
(
pipeline
.
status
).
to
eq
(
"skipped"
)
expect
(
commit
.
yaml_errors
).
to
be_nil
expect
(
pipeline
.
yaml_errors
).
to
be_nil
end
end
end
end
...
@@ -136,40 +136,40 @@ describe CreateCommitBuildsService, services: true do
...
@@ -136,40 +136,40 @@ describe CreateCommitBuildsService, services: true do
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:ci_yaml_file
)
{
gitlab_ci_yaml
}
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:ci_yaml_file
)
{
gitlab_ci_yaml
}
commits
=
[{
message:
"message"
}]
commits
=
[{
message:
"message"
}]
commit
=
service
.
execute
(
project
,
user
,
pipeline
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/master'
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
commits:
commits
)
)
expect
(
commit
).
to
be_persisted
expect
(
pipeline
).
to
be_persisted
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
expect
(
pipeline
.
builds
.
count
(
:all
)).
to
eq
(
2
)
commit
=
service
.
execute
(
project
,
user
,
pipeline
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/master'
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
commits:
commits
)
)
expect
(
commit
).
to
be_persisted
expect
(
pipeline
).
to
be_persisted
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
expect
(
pipeline
.
builds
.
count
(
:all
)).
to
eq
(
2
)
end
end
it
"creates commit with failed status if yaml is invalid"
do
it
"creates commit with failed status if yaml is invalid"
do
stub_ci_
commit
_yaml_file
(
'invalid: file'
)
stub_ci_
pipeline
_yaml_file
(
'invalid: file'
)
commits
=
[{
message:
"some message"
}]
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
user
,
pipeline
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
before:
'00000000'
,
after:
'31das312'
,
after:
'31das312'
,
commits:
commits
commits:
commits
)
)
expect
(
commit
).
to
be_persisted
expect
(
pipeline
).
to
be_persisted
expect
(
commit
.
status
).
to
eq
(
"failed"
)
expect
(
pipeline
.
status
).
to
eq
(
"failed"
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
pipeline
.
builds
.
any?
).
to
be
false
end
end
end
end
end
end
spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb
View file @
20c7144e
...
@@ -6,7 +6,7 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
...
@@ -6,7 +6,7 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:sha
)
{
'1234567890abcdef1234567890abcdef12345678'
}
let
(
:sha
)
{
'1234567890abcdef1234567890abcdef12345678'
}
let
(
:pipeline
)
{
create
(
:ci_
commit
_with_one_job
,
ref:
merge_request
.
source_branch
,
project:
project
,
sha:
sha
)
}
let
(
:pipeline
)
{
create
(
:ci_
pipeline
_with_one_job
,
ref:
merge_request
.
source_branch
,
project:
project
,
sha:
sha
)
}
let
(
:service
)
{
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
let
(
:service
)
{
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
let
(
:todo_service
)
{
TodoService
.
new
}
let
(
:todo_service
)
{
TodoService
.
new
}
...
...
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
View file @
20c7144e
...
@@ -10,7 +10,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
...
@@ -10,7 +10,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
source_project:
project
,
target_project:
project
,
state:
"opened"
)
source_project:
project
,
target_project:
project
,
state:
"opened"
)
end
end
let
(
:pipeline
)
{
create
(
:ci_
commit
_with_one_job
,
ref:
mr_merge_if_green_enabled
.
source_branch
,
project:
project
)
}
let
(
:pipeline
)
{
create
(
:ci_
pipeline
_with_one_job
,
ref:
mr_merge_if_green_enabled
.
source_branch
,
project:
project
)
}
let
(
:service
)
{
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
let
(
:service
)
{
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
describe
"#execute"
do
describe
"#execute"
do
...
...
spec/services/system_note_service_spec.rb
View file @
20c7144e
...
@@ -208,7 +208,7 @@ describe SystemNoteService, services: true do
...
@@ -208,7 +208,7 @@ describe SystemNoteService, services: true do
end
end
describe
'.merge_when_build_succeeds'
do
describe
'.merge_when_build_succeeds'
do
let
(
:
ci_commit
)
{
build
(
:ci_commit
_without_jobs
)}
let
(
:
pipeline
)
{
build
(
:ci_pipeline
_without_jobs
)}
let
(
:noteable
)
do
let
(
:noteable
)
do
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
end
end
...
@@ -223,7 +223,6 @@ describe SystemNoteService, services: true do
...
@@ -223,7 +223,6 @@ describe SystemNoteService, services: true do
end
end
describe
'.cancel_merge_when_build_succeeds'
do
describe
'.cancel_merge_when_build_succeeds'
do
let
(
:ci_commit
)
{
build
(
:ci_commit_without_jobs
)
}
let
(
:noteable
)
do
let
(
:noteable
)
do
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
end
end
...
...
spec/support/stub_gitlab_calls.rb
View file @
20c7144e
...
@@ -13,11 +13,11 @@ module StubGitlabCalls
...
@@ -13,11 +13,11 @@ module StubGitlabCalls
allow_any_instance_of
(
Network
).
to
receive
(
:projects
)
{
project_hash_array
}
allow_any_instance_of
(
Network
).
to
receive
(
:projects
)
{
project_hash_array
}
end
end
def
stub_ci_
commit
_to_return_yaml_file
def
stub_ci_
pipeline
_to_return_yaml_file
stub_ci_
commit
_yaml_file
(
gitlab_ci_yaml
)
stub_ci_
pipeline
_yaml_file
(
gitlab_ci_yaml
)
end
end
def
stub_ci_
commit
_yaml_file
(
ci_yaml
)
def
stub_ci_
pipeline
_yaml_file
(
ci_yaml
)
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:ci_yaml_file
)
{
ci_yaml
}
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:ci_yaml_file
)
{
ci_yaml
}
end
end
...
...
spec/workers/post_receive_spec.rb
View file @
20c7144e
...
@@ -53,13 +53,13 @@ describe PostReceive do
...
@@ -53,13 +53,13 @@ describe PostReceive do
subject
{
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
}
subject
{
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
}
context
"creates a Ci::Pipeline for every change"
do
context
"creates a Ci::Pipeline for every change"
do
before
{
stub_ci_
commit
_to_return_yaml_file
}
before
{
stub_ci_
pipeline
_to_return_yaml_file
}
it
{
expect
{
subject
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
2
)
}
it
{
expect
{
subject
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
2
)
}
end
end
context
"does not create a Ci::Pipeline"
do
context
"does not create a Ci::Pipeline"
do
before
{
stub_ci_
commit
_yaml_file
(
nil
)
}
before
{
stub_ci_
pipeline
_yaml_file
(
nil
)
}
it
{
expect
{
subject
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
}
it
{
expect
{
subject
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
}
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