Commit 655b2640 authored by Benedikt Huss's avatar Benedikt Huss

Merge request widget displays TeamCity build state and code coverage correctly again

parent 915a4193
...@@ -68,13 +68,13 @@ class @MergeRequestWidget ...@@ -68,13 +68,13 @@ class @MergeRequestWidget
$.getJSON @opts.ci_status_url, (data) => $.getJSON @opts.ci_status_url, (data) =>
@readyForCICheck = true @readyForCICheck = true
if @firstCICheck || @opts.ci_status is ''
if @firstCICheck if @firstCICheck
@firstCICheck = false @firstCICheck = false
@opts.ci_status = data.status @opts.ci_status = data.status
@showCIStatus data.status
if @opts.ci_status is '' if data.coverage
@opts.ci_status = data.status @showCICoverage data.coverage
return
if data.status isnt @opts.ci_status and data.status? if data.status isnt @opts.ci_status and data.status?
@showCIStatus data.status @showCIStatus data.status
......
#= require merge_request_widget
describe 'MergeRequestWidget', ->
beforeEach ->
window.notifyPermissions = () ->
@opts = {ci_status_url:"http://sampledomain.local/ci/getstatus",ci_status:""}
@class = new MergeRequestWidget(@opts)
@ciStatusData = {"title":"Sample MR title","sha":"12a34bc5","status":"success","coverage":98}
describe 'getCIStatus', ->
beforeEach ->
spyOn(jQuery, 'getJSON').and.callFake (req, cb) =>
cb(@ciStatusData)
it 'should call showCIStatus even if a notification should not be displayed', ->
spy = spyOn(@class, 'showCIStatus').and.stub()
@class.getCIStatus(false)
expect(spy).toHaveBeenCalledWith(@ciStatusData.status)
it 'should call showCIStatus when a notification should be displayed', ->
spy = spyOn(@class, 'showCIStatus').and.stub()
@class.getCIStatus(true)
expect(spy).toHaveBeenCalledWith(@ciStatusData.status)
it 'should call showCICoverage when the coverage rate is set', ->
spy = spyOn(@class, 'showCICoverage').and.stub()
@class.getCIStatus(true)
expect(spy).toHaveBeenCalledWith(@ciStatusData.coverage)
it 'should not call showCICoverage when the coverage rate is not set', ->
@ciStatusData.coverage = null
spy = spyOn(@class, 'showCICoverage').and.stub()
@class.getCIStatus(true)
expect(spy).not.toHaveBeenCalled()
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