Add specs for new pipeline and build action events

This commit is contained in:
Grzegorz Bizon 2017-03-06 13:01:10 +01:00
parent a263e37051
commit 3afd7fb29b
3 changed files with 32 additions and 1 deletions

View file

@ -20,6 +20,30 @@ describe Ci::Build, :models do
it { is_expected.to validate_presence_of :ref } it { is_expected.to validate_presence_of :ref }
it { is_expected.to respond_to :trace_html } it { is_expected.to respond_to :trace_html }
describe '#actionize' do
context 'when build is a created' do
before do
build.update_column(:status, :created)
end
it 'makes build a manual action' do
expect(build.actionize).to be true
expect(build.reload).to be_manual
end
end
context 'when build is not created' do
before do
build.update_column(:status, :pending)
end
it 'does not change build status' do
expect(build.actionize).to be false
expect(build.reload).to be_pending
end
end
end
describe '#any_runners_online?' do describe '#any_runners_online?' do
subject { build.any_runners_online? } subject { build.any_runners_online? }

View file

@ -24,6 +24,14 @@ describe Ci::Pipeline, models: true do
it { is_expected.to respond_to :git_author_email } it { is_expected.to respond_to :git_author_email }
it { is_expected.to respond_to :short_sha } it { is_expected.to respond_to :short_sha }
describe '#block' do
it 'changes pipeline status to manual' do
expect(pipeline.block).to be true
expect(pipeline.reload).to be_manual
expect(pipeline.reload).to be_blocked
end
end
describe '#valid_commit_sha' do describe '#valid_commit_sha' do
context 'commit.sha can not start with 00000000' do context 'commit.sha can not start with 00000000' do
before do before do

View file

@ -342,7 +342,6 @@ describe Ci::ProcessPipelineService, '#execute', :services do
expect(builds_statuses).to eq %w[success success success manual] expect(builds_statuses).to eq %w[success success success manual]
expect(pipeline.reload).to be_manual expect(pipeline.reload).to be_manual
# TODO, expect(pipeline.reload).to be_started
expect(pipeline.reload).to be_blocked expect(pipeline.reload).to be_blocked
expect(pipeline.reload).not_to be_active expect(pipeline.reload).not_to be_active
expect(pipeline.reload).not_to be_complete expect(pipeline.reload).not_to be_complete