Commit 0ae7c954 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add specs for build status helper class

parent 364072b7
...@@ -16,6 +16,14 @@ FactoryGirl.define do ...@@ -16,6 +16,14 @@ FactoryGirl.define do
commit factory: :ci_commit commit factory: :ci_commit
trait :success do
status 'success'
end
trait :failed do
status 'failed'
end
trait :canceled do trait :canceled do
status 'canceled' status 'canceled'
end end
......
require 'spec_helper'
describe Ci::Status do
describe '.get_status' do
subject { described_class.get_status(builds) }
context 'all builds successful' do
let(:builds) { Array.new(2) { create(:ci_build, :success) } }
it { is_expected.to eq 'success' }
end
context 'at least one build failed' do
let(:builds) { [create(:ci_build, :success), create(:ci_build, :failed)] }
it { is_expected.to eq 'failed' }
end
end
end
...@@ -5,16 +5,24 @@ describe Ci::CreateBuildsService, services: true do ...@@ -5,16 +5,24 @@ describe Ci::CreateBuildsService, services: true do
let(:user) { create(:user) } let(:user) { create(:user) }
describe '#execute' do describe '#execute' do
# Using stubbed .gitlab-ci.yml created in commit factory
#
subject do subject do
described_class.new.execute(commit, stage, 'master', nil, user, nil, status) described_class.new.execute(commit, 'test', 'master', nil, user, nil, status)
end end
context 'stubbed .gitlab-ci.yml' do context 'next builds available' do
let(:stage) { 'test' }
let(:status) { 'success' } let(:status) { 'success' }
it { is_expected.to be_an_instance_of Array } it { is_expected.to be_an_instance_of Array }
it { is_expected.to all(be_an_instance_of Ci::Build) } it { is_expected.to all(be_an_instance_of Ci::Build) }
end end
context 'builds skipped' do
let(:status) { 'skipped' }
it { is_expected.to be_empty }
end
end end
end end
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