Skip to content
This repository was archived by the owner on Sep 27, 2018. It is now read-only.

Commit 91e58f8

Browse files
committed
Merge pull request #9 from DCas/bug/status-image-format
Bug/status image format
2 parents 4762d06 + 807c2dc commit 91e58f8

2 files changed

Lines changed: 47 additions & 16 deletions

File tree

lib/codeship/status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def initialize(uuid, options = {})
1414
end
1515

1616
def status
17-
image.scan(/status_(.*).png/).flatten.first.to_sym
17+
image.scan(/status_(.*).(png|gif)/).flatten.first.to_sym
1818
end
1919

2020
private

spec/status_spec.rb

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,59 @@
22

33
RSpec.describe Codeship::Status do
44
context 'parsing the project status' do
5-
Codeship::Status::STATES.each do |state|
6-
it "should parse #{state}" do
5+
context 'of a project with completed build' do
6+
Codeship::Status::STATES.each do |state|
7+
it "should parse #{state}" do
78

8-
stub_request(:head, "https://codeship.com/projects/#{state}/status").
9-
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
10-
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.png\""})
9+
stub_request(:head, "https://codeship.com/projects/#{state}/status").
10+
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
11+
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.png\""})
1112

12-
project_status = Codeship::Status.new(state)
13-
expect(project_status.status).to eq(state)
13+
project_status = Codeship::Status.new(state)
14+
expect(project_status.status).to eq(state)
15+
end
16+
end
17+
end
18+
19+
context 'of a project with active build' do
20+
Codeship::Status::STATES.each do |state|
21+
it "should parse #{state}" do
22+
23+
stub_request(:head, "https://codeship.com/projects/#{state}/status").
24+
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
25+
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.gif\""})
26+
27+
project_status = Codeship::Status.new(state)
28+
expect(project_status.status).to eq(state)
29+
end
1430
end
1531
end
1632
end
1733

1834
context 'parsing the project status on a certain branch' do
19-
Codeship::Status::STATES.each do |state|
20-
it "should parse #{state}" do
21-
stub_request(:head, "https://codeship.com/projects/#{state}/status?branch=master").
22-
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
23-
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.png\""})
24-
25-
project_status = Codeship::Status.new(state, branch: 'master')
26-
expect(project_status.status).to eq(state)
35+
context 'of a project with completed build' do
36+
Codeship::Status::STATES.each do |state|
37+
it "should parse #{state}" do
38+
stub_request(:head, "https://codeship.com/projects/#{state}/status?branch=master").
39+
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
40+
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.png\""})
41+
42+
project_status = Codeship::Status.new(state, branch: 'master')
43+
expect(project_status.status).to eq(state)
44+
end
45+
end
46+
end
47+
48+
context 'of a project with active build' do
49+
Codeship::Status::STATES.each do |state|
50+
it "should parse #{state}" do
51+
stub_request(:head, "https://codeship.com/projects/#{state}/status?branch=master").
52+
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
53+
to_return(status: 200, body: "", headers: {'Content-Disposition' => "inline; filename=\"status_#{state}.gif\""})
54+
55+
project_status = Codeship::Status.new(state, branch: 'master')
56+
expect(project_status.status).to eq(state)
57+
end
2758
end
2859
end
2960
end

0 commit comments

Comments
 (0)