Add spec for Build::Factory
This commit is contained in:
parent
6d4511135d
commit
19fb42b5ca
1 changed files with 49 additions and 0 deletions
|
@ -319,4 +319,53 @@ describe Gitlab::Ci::Status::Build::Factory do
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue