summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-05-08 22:07:40 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2016-05-11 11:01:05 +0200
commitd1ba09869542fa4d2198c6199cf820bc75fcbb63 (patch)
treee62fc19b1219d6500f49e646677f1940016dfc7a
parentafcc33b79777f008c6e4ffa2b9675101abdefb0c (diff)
downloadgitlab-ce-d1ba09869542fa4d2198c6199cf820bc75fcbb63.tar.gz
Merge branch 'fix-build-notification-on-merge-page-change' into 'master'
Fix build notification on merge request page change even if the build status didn't change ## What does this MR do? This MR contains a bugfix for #17357 which was introduced by !3998. The notification are now only shown on status changes, and not when switching between different merge requests. ## Are there points in the code the reviewer needs to double check? Check implementation ## Why was this MR needed? Because auf a bug introduced in !3998. ## What are the relevant issue numbers? #17357 Closes #17357 See merge request !4086
-rw-r--r--CHANGELOG3
-rw-r--r--app/assets/javascripts/merge_request_widget.js.coffee9
-rw-r--r--app/views/projects/merge_requests/widget/_heading.html.haml7
-rw-r--r--spec/javascripts/merge_request_widget_spec.js.coffee6
4 files changed, 15 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ed9edec98d8..6571e464e6f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -42,6 +42,9 @@ v 8.7.4
- Fix links on wiki pages for relative url setups. !4026 (Artem Sidorenko)
- Links for Redmine issue references are generated correctly again (Benedikt Huss)
+v 8.7.4
+ - Fix always showing build notification message when switching between merge requests
+
v 8.7.3
- Emails, Gitlab::Email::Message, Gitlab::Diff, and Premailer::Adapter::Nokogiri are now instrumented
- Merge request widget displays TeamCity build state and code coverage correctly again.
diff --git a/app/assets/javascripts/merge_request_widget.js.coffee b/app/assets/javascripts/merge_request_widget.js.coffee
index 17a5a057a94..f58647988a2 100644
--- a/app/assets/javascripts/merge_request_widget.js.coffee
+++ b/app/assets/javascripts/merge_request_widget.js.coffee
@@ -9,11 +9,12 @@ class @MergeRequestWidget
constructor: (@opts) ->
$('#modal_merge_info').modal(show: false)
@firstCICheck = true
- @readyForCICheck = true
+ @readyForCICheck = false
clearInterval @fetchBuildStatusInterval
@clearEventListeners()
@addEventListeners()
+ @getCIStatus(false)
@pollCIStatus()
notifyPermissions()
@@ -71,7 +72,7 @@ class @MergeRequestWidget
if data.status is ''
return
- if @firstCiCheck || data.status isnt @opts.ci_status and data.status?
+ if @firstCICheck || data.status isnt @opts.ci_status and data.status?
@opts.ci_status = data.status
@showCIStatus data.status
if data.coverage
@@ -79,7 +80,7 @@ class @MergeRequestWidget
# The first check should only update the UI, a notification
# should only be displayed on status changes
- if showNotification and not @firstCiCheck
+ if showNotification and not @firstCICheck
status = @ciLabelForStatus(data.status)
if status is "preparing"
@@ -102,7 +103,7 @@ class @MergeRequestWidget
@close()
Turbolinks.visit _this.opts.builds_path
)
- @firstCiCheck = false
+ @firstCICheck = false
showCIStatus: (state) ->
$('.ci_widget').hide()
diff --git a/app/views/projects/merge_requests/widget/_heading.html.haml b/app/views/projects/merge_requests/widget/_heading.html.haml
index 2ec0d20a879..4d381754610 100644
--- a/app/views/projects/merge_requests/widget/_heading.html.haml
+++ b/app/views/projects/merge_requests/widget/_heading.html.haml
@@ -41,9 +41,4 @@
.ci_widget.ci-error{style: "display:none"}
= icon("times-circle")
- Could not connect to the CI server. Please check your settings and try again.
-
- :javascript
- $(function() {
- merge_request_widget.getCIStatus(false);
- });
+ Could not connect to the CI server. Please check your settings and try again. \ No newline at end of file
diff --git a/spec/javascripts/merge_request_widget_spec.js.coffee b/spec/javascripts/merge_request_widget_spec.js.coffee
index c0bd8a29e43..92b7eeb1116 100644
--- a/spec/javascripts/merge_request_widget_spec.js.coffee
+++ b/spec/javascripts/merge_request_widget_spec.js.coffee
@@ -47,3 +47,9 @@ describe 'MergeRequestWidget', ->
spy = spyOn(@class, 'showCICoverage').and.stub()
@class.getCIStatus(false)
expect(spy).not.toHaveBeenCalled()
+
+ it 'should not display a notification on the first check after the widget has been created', ->
+ spy = spyOn(window, 'notify')
+ @class = new MergeRequestWidget(@opts)
+ @class.getCIStatus(true)
+ expect(spy).not.toHaveBeenCalled()