From 843bc44aa9dea8a19af21dd13a82ecc02bf8840c Mon Sep 17 00:00:00 2001
From: Phil Hughes <me@iamphill.com>
Date: Wed, 6 Apr 2016 17:04:22 +0100
Subject: [PATCH] Preparing build text

---
 .../javascripts/merge_request_widget.js.coffee   | 16 +++++++++++++---
 .../merge_requests/widget/_show.html.haml        |  9 ++++++++-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/app/assets/javascripts/merge_request_widget.js.coffee b/app/assets/javascripts/merge_request_widget.js.coffee
index 63f75be2dad..a522f9189ab 100644
--- a/app/assets/javascripts/merge_request_widget.js.coffee
+++ b/app/assets/javascripts/merge_request_widget.js.coffee
@@ -47,7 +47,7 @@ class @MergeRequestWidget
       $('.mr-state-widget').replaceWith(data)
 
   ciLabelForStatus: (status) ->
-    if status == 'success'
+    if status is 'success'
       'passed'
     else
       status
@@ -86,12 +86,22 @@ class @MergeRequestWidget
           @showCICoverage data.coverage
 
         if showNotification
-          message = @opts.ci_message.replace('{{status}}', @ciLabelForStatus(data.status))
+          status = @ciLabelForStatus(data.status)
+
+          if status is "preparing"
+            title = @opts.ci_title.preparing
+            status = status.charAt(0).toUpperCase() + status.slice(1);
+            message = @opts.ci_message.preparing.replace('{{status}}', status)
+          else
+            title = @opts.ci_title.normal
+            message = @opts.ci_message.normal.replace('{{status}}', status)
+
+          title = title.replace('{{status}}', status)
           message = message.replace('{{sha}}', data.sha)
           message = message.replace('{{title}}', data.title)
 
           notify(
-            "Build #{@ciLabelForStatus(data.status)}",
+            title,
             message,
             @opts.gitlab_icon,
             ->
diff --git a/app/views/projects/merge_requests/widget/_show.html.haml b/app/views/projects/merge_requests/widget/_show.html.haml
index 003477dda1a..804ca3783e3 100644
--- a/app/views/projects/merge_requests/widget/_show.html.haml
+++ b/app/views/projects/merge_requests/widget/_show.html.haml
@@ -14,8 +14,15 @@
     ci_status_url: "#{ci_status_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}",
     gitlab_icon: "#{asset_path 'gitlab_logo.png'}",
     ci_status: "",
-    ci_message: "Build {{status}} for \"{{title}}\"",
+    ci_message: {
+      normal: "Build {{status}} for \"{{title}}\"",
+      preparing: "{{status}} build for \"{{title}}\""
+    },
     ci_enable: #{@project.ci_service ? "true" : "false"},
+    ci_title: {
+      preparing: "{{status}} build",
+      normal: "Build {{status}}"
+    },
     builds_path: "#{builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}"
   };
 
-- 
GitLab