Commit 8ab4228b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve broadcast message logic

Expect broadcast message API endpoint to return 200 with empty JSON if
no broadcast messages available
parent b0979371
v2.5.1
- Expect broadcast message to return empty JSON if no message now
v2.5.0
- Support git-annex tool (disabled by default)
- Add rubocop (Ruby static code analyzer) for development
......
......@@ -45,11 +45,7 @@ class GitlabNet
def broadcast_message
resp = get("#{host}/broadcast_message")
if resp.code == '200'
JSON.parse(resp.body) rescue nil
else
nil
end
JSON.parse(resp.body) rescue {}
end
def check
......
......@@ -20,11 +20,13 @@ class GitlabPostReceive
begin
broadcast_message = GitlabNet.new.broadcast_message
if broadcast_message
if broadcast_message.has_key?("message")
puts
print_broadcast_message(broadcast_message["message"])
end
rescue GitlabNet::ApiUnreachableError
nil
end
end
......
......@@ -70,7 +70,7 @@ describe GitlabNet, vcr: true do
it 'should return nil' do
VCR.use_cassette("broadcast_message-none") do
result = gitlab_net.broadcast_message
result.should == nil
result.should == {}
end
end
end
......
......@@ -15,7 +15,7 @@ http_interactions:
- Ruby
response:
status:
code: 404
code: 200
message: Not Found
headers:
Server:
......@@ -32,7 +32,7 @@ http_interactions:
- 200 OK
body:
encoding: UTF-8
string: '{"message":"404 Not Found"}'
string: '{}'
http_version:
recorded_at: Sat, 07 Feb 2015 16:45:35 GMT
recorded_with: VCR 2.4.0
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