Commit 19fb42b5 authored by Shinya Maeda's avatar Shinya Maeda Committed by Alessio Caiazza

Add spec for Build::Factory

parent 6d451113
...@@ -319,4 +319,53 @@ describe Gitlab::Ci::Status::Build::Factory do ...@@ -319,4 +319,53 @@ describe Gitlab::Ci::Status::Build::Factory do
end end
end end
end end
context 'when build is a delayed action' do
let(:build) { create(:ci_build, :scheduled) }
it 'matches correct core status' do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Scheduled
end
it 'matches correct extended statuses' do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Scheduled,
Gitlab::Ci::Status::Build::Play,
Gitlab::Ci::Status::Build::Action]
end
it 'fabricates action detailed status' do
expect(status).to be_a Gitlab::Ci::Status::Build::Action
end
it 'fabricates status with correct details' do
expect(status.text).to eq 'scheduled'
expect(status.group).to eq 'scheduled'
expect(status.icon).to eq 'status_scheduled'
expect(status.favicon).to eq 'favicon_status_scheduled'
expect(status.illustration).to include(:image, :size, :title, :content)
expect(status.label).to include 'manual play action'
expect(status).to have_details
expect(status.action_path).to include 'play'
end
context 'when user has ability to play action' do
it 'fabricates status that has action' do
expect(status).to have_action
end
end
context 'when user does not have ability to play action' do
before do
allow(build.project).to receive(:empty_repo?).and_return(false)
create(:protected_branch, :no_one_can_push,
name: build.ref, project: build.project)
end
it 'fabricates status that has no action' do
expect(status).not_to have_action
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