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 ...@@ -117,7 +117,7 @@ module Ci
# get status for all prior builds # get status for all prior builds
prior_builds = latest_builds.reject { |other_build| next_stages.include?(other_build.stage) } 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 # create builds for next stages based
next_stages.any? do |stage| next_stages.any? do |stage|
...@@ -185,7 +185,7 @@ module Ci ...@@ -185,7 +185,7 @@ module Ci
private private
def update_status def update_status
status = self.status =
if yaml_errors.present? if yaml_errors.present?
'failed' 'failed'
else else
...@@ -194,17 +194,17 @@ module Ci ...@@ -194,17 +194,17 @@ module Ci
end end
def update_started_at def update_started_at
started_at = self.started_at =
statuses.minimum(:started_at) statuses.minimum(:started_at)
end end
def update_finished_at def update_finished_at
finished_at = self.finished_at =
statuses.maximum(:finished_at) statuses.maximum(:finished_at)
end end
def update_duration def update_duration
duration = begin self.duration = begin
duration_array = latest.map(&:duration).compact duration_array = latest.map(&:duration).compact
duration_array.reduce(:+).to_i duration_array.reduce(:+).to_i
end end
......
...@@ -14,6 +14,8 @@ module CiStatus ...@@ -14,6 +14,8 @@ module CiStatus
'running' 'running'
elsif objs.all?(&:canceled?) elsif objs.all?(&:canceled?)
'canceled' 'canceled'
elsif objs.all?(&:skipped?)
'skipped'
else else
'failed' 'failed'
end end
......
...@@ -10,16 +10,16 @@ module SharedBuilds ...@@ -10,16 +10,16 @@ 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) @ci_commit = create(:ci_commit, project: @project, sha: @project.commit.sha, ref: 'master')
@build = create(:ci_build_with_coverage, commit: @ci_commit) @build = create(:ci_build_with_coverage, commit: @ci_commit)
end end
step 'recent build is successful' do step 'recent build is successful' do
@build.update_column(:status, 'success') @build.update(status: 'success')
end end
step 'recent build failed' do step 'recent build failed' do
@build.update_column(:status, 'failed') @build.update(status: 'failed')
end end
step 'project has another build that is running' do step 'project has another build that is running' do
......
...@@ -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' commit = create :ci_commit, 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
......
require 'spec_helper' require 'spec_helper'
describe Ci::Status do describe CiStatus do
describe '.get_status' do before do
subject { described_class.get_status(statuses) } @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 shared_examples 'build status summary' do
context 'all successful' 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