Merge request widget displays TeamCity build state and code coverage correctly again
This commit is contained in:
parent
915a4193b4
commit
655b2640ae
2 changed files with 41 additions and 6 deletions
|
@ -68,13 +68,13 @@ class @MergeRequestWidget
|
|||
$.getJSON @opts.ci_status_url, (data) =>
|
||||
@readyForCICheck = true
|
||||
|
||||
if @firstCICheck
|
||||
@firstCICheck = false
|
||||
if @firstCICheck || @opts.ci_status is ''
|
||||
if @firstCICheck
|
||||
@firstCICheck = false
|
||||
@opts.ci_status = data.status
|
||||
|
||||
if @opts.ci_status is ''
|
||||
@opts.ci_status = data.status
|
||||
return
|
||||
@showCIStatus data.status
|
||||
if data.coverage
|
||||
@showCICoverage data.coverage
|
||||
|
||||
if data.status isnt @opts.ci_status and data.status?
|
||||
@showCIStatus data.status
|
||||
|
|
35
spec/javascripts/merge_request_widget_spec.js.coffee
Normal file
35
spec/javascripts/merge_request_widget_spec.js.coffee
Normal file
|
@ -0,0 +1,35 @@
|
|||
#= 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()
|
Loading…
Reference in a new issue