summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-08-11 20:54:02 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-08-11 21:32:16 +0200
commit6a6a69f4afbe0107a75df018b662f02b5ec0166a (patch)
treeb7a49ab9b0913d90251245648a885de9442708c9 /spec
parentd983c5bd4671d989edf3741d0db0a54dcef9c3b6 (diff)
downloadgitlab-ce-6a6a69f4afbe0107a75df018b662f02b5ec0166a.tar.gz
Use state machine for pipeline event processing
Diffstat (limited to 'spec')
-rw-r--r--spec/features/pipelines_spec.rb4
-rw-r--r--spec/lib/ci/charts_spec.rb1
-rw-r--r--spec/models/ci/pipeline_spec.rb38
-rw-r--r--spec/requests/api/builds_spec.rb4
-rw-r--r--spec/services/ci/image_for_build_service_spec.rb2
5 files changed, 4 insertions, 45 deletions
diff --git a/spec/features/pipelines_spec.rb b/spec/features/pipelines_spec.rb
index f88b8f8e60b..248e44a93aa 100644
--- a/spec/features/pipelines_spec.rb
+++ b/spec/features/pipelines_spec.rb
@@ -34,7 +34,6 @@ describe "Pipelines" do
let!(:running) { create(:ci_build, :running, pipeline: pipeline, stage: 'test', commands: 'test') }
before do
- pipeline.reload_status!
visit namespace_project_pipelines_path(project.namespace, project)
end
@@ -53,7 +52,6 @@ describe "Pipelines" do
let!(:failed) { create(:ci_build, :failed, pipeline: pipeline, stage: 'test', commands: 'test') }
before do
- pipeline.reload_status!
visit namespace_project_pipelines_path(project.namespace, project)
end
@@ -87,7 +85,6 @@ describe "Pipelines" do
let!(:running) { create(:generic_commit_status, status: 'running', pipeline: pipeline, stage: 'test') }
before do
- pipeline.reload_status!
visit namespace_project_pipelines_path(project.namespace, project)
end
@@ -104,7 +101,6 @@ describe "Pipelines" do
let!(:failed) { create(:generic_commit_status, status: 'failed', pipeline: pipeline, stage: 'test') }
before do
- pipeline.reload_status!
visit namespace_project_pipelines_path(project.namespace, project)
end
diff --git a/spec/lib/ci/charts_spec.rb b/spec/lib/ci/charts_spec.rb
index 2cd6b00dad6..034ea098193 100644
--- a/spec/lib/ci/charts_spec.rb
+++ b/spec/lib/ci/charts_spec.rb
@@ -5,7 +5,6 @@ describe Ci::Charts, lib: true do
before do
@pipeline = FactoryGirl.create(:ci_pipeline)
FactoryGirl.create(:ci_build, pipeline: @pipeline)
- @pipeline.reload_status!
end
it 'returns build times in minutes' do
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 9a9720cfbfc..eb762276cbe 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
describe Ci::Pipeline, models: true do
let(:project) { FactoryGirl.create :empty_project }
- let(:pipeline) { FactoryGirl.create :ci_pipeline, project: project }
+ let(:pipeline) { FactoryGirl.create :ci_empty_pipeline, project: project }
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:user) }
@@ -51,25 +51,6 @@ describe Ci::Pipeline, models: true do
end
end
- describe "#finished_at" do
- let(:pipeline) { FactoryGirl.create :ci_pipeline }
-
- it "returns finished_at of latest build" do
- build = FactoryGirl.create :ci_build, pipeline: pipeline, finished_at: Time.now - 60
- FactoryGirl.create :ci_build, pipeline: pipeline, finished_at: Time.now - 120
- pipeline.reload_status!
-
- expect(pipeline.finished_at.to_i).to eq(build.finished_at.to_i)
- end
-
- it "returns nil if there is no finished build" do
- FactoryGirl.create :ci_not_started_build, pipeline: pipeline
- pipeline.reload_status!
-
- expect(pipeline.finished_at).to be_nil
- end
- end
-
describe "coverage" do
let(:project) { FactoryGirl.create :empty_project, build_coverage_regex: "/.*/" }
let(:pipeline) { FactoryGirl.create :ci_empty_pipeline, project: project }
@@ -139,31 +120,20 @@ describe Ci::Pipeline, models: true do
end
end
- describe '#reload_status!' do
+ describe '#update_counters' do
let(:pipeline) { create :ci_empty_pipeline, project: project }
- context 'dependent objects' do
- let(:commit_status) { create :commit_status, :pending, pipeline: pipeline }
-
- it 'executes reload_status! after succeeding dependent object' do
- expect(pipeline).to receive(:reload_status!).and_return(true)
-
- commit_status.success
- end
- end
-
context 'updates' do
let(:current) { Time.now.change(usec: 0) }
let(:build) { FactoryGirl.create :ci_build, pipeline: pipeline, started_at: current - 120, finished_at: current - 60 }
before do
- build
- pipeline.reload_status!
+ build.skip
end
[:status, :started_at, :finished_at, :duration].each do |param|
it "#{param}" do
- expect(pipeline.send(param)).to eq(build.send(param))
+ expect(pipeline.reload.send(param)).to eq(build.send(param))
end
end
end
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index a4cdd8f3140..966d302dfd3 100644
--- a/spec/requests/api/builds_spec.rb
+++ b/spec/requests/api/builds_spec.rb
@@ -238,10 +238,6 @@ describe API::API, api: true do
it { expect(response.headers).to include(download_headers) }
end
- before do
- pipeline.reload_status!
- end
-
context 'with regular branch' do
before do
pipeline.update(ref: 'master',
diff --git a/spec/services/ci/image_for_build_service_spec.rb b/spec/services/ci/image_for_build_service_spec.rb
index 259062406c7..c931c3e4829 100644
--- a/spec/services/ci/image_for_build_service_spec.rb
+++ b/spec/services/ci/image_for_build_service_spec.rb
@@ -14,7 +14,6 @@ module Ci
context 'branch name' do
before { allow(project).to receive(:commit).and_return(OpenStruct.new(sha: commit_sha)) }
before { build.run! }
- before { pipeline.reload_status! }
let(:image) { service.execute(project, ref: 'master') }
it { expect(image).to be_kind_of(OpenStruct) }
@@ -32,7 +31,6 @@ module Ci
context 'commit sha' do
before { build.run! }
- before { pipeline.reload_status! }
let(:image) { service.execute(project, sha: build.sha) }
it { expect(image).to be_kind_of(OpenStruct) }