Commit ac50f9dd authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix rest of rspec and spinach tests

parent 52be9e20
......@@ -117,7 +117,7 @@ module Ci
# get status for all prior builds
prior_builds = latest_builds.reject { |other_build| next_stages.include?(other_build.stage) }
status = Ci::Status.get_status(prior_builds)
status = prior_builds.status
# create builds for next stages based
next_stages.any? do |stage|
......@@ -185,7 +185,7 @@ module Ci
private
def update_status
status =
self.status =
if yaml_errors.present?
'failed'
else
......@@ -194,17 +194,17 @@ module Ci
end
def update_started_at
started_at =
self.started_at =
statuses.minimum(:started_at)
end
def update_finished_at
finished_at =
self.finished_at =
statuses.maximum(:finished_at)
end
def update_duration
duration = begin
self.duration = begin
duration_array = latest.map(&:duration).compact
duration_array.reduce(:+).to_i
end
......
......@@ -5,7 +5,7 @@ module CiStatus
def status
objs = all.to_a
if objs.none?
nil
nil
elsif objs.all? { |status| status.success? || status.try(:ignored?) }
'success'
elsif objs.all?(&:pending?)
......@@ -14,6 +14,8 @@ module CiStatus
'running'
elsif objs.all?(&:canceled?)
'canceled'
elsif objs.all?(&:skipped?)
'skipped'
else
'failed'
end
......@@ -56,4 +58,4 @@ module CiStatus
def complete?
canceled? || success? || failed?
end
end
\ No newline at end of file
end
......@@ -22,7 +22,7 @@ module Ci
builds_attrs.map do |build_attrs|
# don't create the same build twice
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,
:commands,
:tag_list,
......
......@@ -10,16 +10,16 @@ module SharedBuilds
end
step 'project has a recent build' do
@ci_commit = create(:ci_commit, project: @project, sha: @project.commit.sha)
@ci_commit = create(:ci_commit, project: @project, sha: @project.commit.sha, ref: 'master')
@build = create(:ci_build_with_coverage, commit: @ci_commit)
end
step 'recent build is successful' do
@build.update_column(:status, 'success')
@build.update(status: 'success')
end
step 'recent build failed' do
@build.update_column(:status, 'failed')
@build.update(status: 'failed')
end
step 'project has another build that is running' do
......
......@@ -230,7 +230,7 @@ module SharedProject
step 'project "Shop" has CI build' do
project = Project.find_by(name: "Shop")
create :ci_commit, project: project, sha: project.commit.sha, ref: 'master'
commit = create :ci_commit, project: project, sha: project.commit.sha, ref: 'master', status: 'skipped'
end
step 'I should see last commit with CI status' do
......
require 'spec_helper'
describe Ci::Status do
describe '.get_status' do
subject { described_class.get_status(statuses) }
describe CiStatus do
before do
@object = Object.new
@object.extend(CiStatus::ClassMethods)
end
describe '.status' do
before do
allow(@object).to receive(:all).and_return(statuses)
end
subject { @object.status }
shared_examples 'build status summary' do
context 'all successful' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment