blob: 4c7094146bbb39ebeba4506fb776ae6b3740a60b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
require 'spec_helper'
describe ImageForBuildService do
let(:service) { ImageForBuildService.new }
let(:project) { FactoryGirl.create(:project) }
let(:commit) { FactoryGirl.create(:commit, project: project, ref: 'master') }
let(:build) { FactoryGirl.create(:build, commit: commit) }
describe :execute do
before { build }
context 'branch name' do
before { build.run! }
let(:image) { service.execute(project, ref: 'master') }
it { image.should be_kind_of(OpenStruct) }
it { image.path.to_s.should include('public/build-running.svg') }
it { image.name.should == 'build-running.svg' }
end
context 'unknown branch name' do
let(:image) { service.execute(project, ref: 'feature') }
it { image.should be_kind_of(OpenStruct) }
it { image.path.to_s.should include('public/build-unknown.svg') }
it { image.name.should == 'build-unknown.svg' }
end
context 'commit sha' do
before { build.run! }
let(:image) { service.execute(project, sha: build.sha) }
it { image.should be_kind_of(OpenStruct) }
it { image.path.to_s.should include('public/build-running.svg') }
it { image.name.should == 'build-running.svg' }
end
context 'unknown commit sha' do
let(:image) { service.execute(project, sha: '0000000') }
it { image.should be_kind_of(OpenStruct) }
it { image.path.to_s.should include('public/build-unknown.svg') }
it { image.name.should == 'build-unknown.svg' }
end
end
end
|