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
......
......@@ -14,6 +14,8 @@ module CiStatus
'running'
elsif objs.all?(&:canceled?)
'canceled'
elsif objs.all?(&:skipped?)
'skipped'
else
'failed'
end
......
......@@ -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