From 1e8271b60bcd16b6fcc20d574c9583d593084eef Mon Sep 17 00:00:00 2001
From: Filipa Lacerda <filipa@gitlab.com>
Date: Fri, 9 Dec 2016 17:24:21 +0000
Subject: [PATCH] Adds new partial for graph icons. Fix tests

---
 app/views/ci/status/_graph_icon_with_name.html.haml  | 12 ++++++++++++
 .../_graph_icon_with_name_and_action.html.haml       |  8 ++++++++
 app/views/ci/status/_icon_with_name.html.haml        |  3 +--
 .../ci/status/_icon_with_name_and_action.html.haml   |  2 +-
 app/views/projects/stage/_graph.html.haml            |  2 +-
 app/views/projects/stage/_in_stage_group.html.haml   |  2 +-
 spec/features/projects/pipelines/pipeline_spec.rb    |  6 +++---
 7 files changed, 27 insertions(+), 8 deletions(-)
 create mode 100644 app/views/ci/status/_graph_icon_with_name.html.haml
 create mode 100644 app/views/ci/status/_graph_icon_with_name_and_action.html.haml

diff --git a/app/views/ci/status/_graph_icon_with_name.html.haml b/app/views/ci/status/_graph_icon_with_name.html.haml
new file mode 100644
index 00000000000..51037a3bd20
--- /dev/null
+++ b/app/views/ci/status/_graph_icon_with_name.html.haml
@@ -0,0 +1,12 @@
+- detailed_status = subject.detailed_status(current_user)
+- details_path = detailed_status.details_path if detailed_status.has_details?
+- klass = "ci-status-icon ci-status-icon-#{detailed_status}"
+- graph_status_icon = "#{detailed_status.icon}_graph"
+
+- if details_path
+  = link_to details_path, class: klass, data: { toggle: 'tooltip', title: "#{subject.name} - #{detailed_status}" } do
+    %span{ class: klass }= custom_icon(graph_status_icon)
+    .ci-status-text= subject.name
+- else
+  %span{ class: klass }= custom_icon(graph_status_icon)
+  .ci-status-text= subject.name
diff --git a/app/views/ci/status/_graph_icon_with_name_and_action.html.haml b/app/views/ci/status/_graph_icon_with_name_and_action.html.haml
new file mode 100644
index 00000000000..525075ced70
--- /dev/null
+++ b/app/views/ci/status/_graph_icon_with_name_and_action.html.haml
@@ -0,0 +1,8 @@
+= render "ci/status/graph_icon_with_name", subject: subject
+
+- detailed_status = subject.detailed_status(current_user)
+- if detailed_status.has_action?
+  = link_to detailed_status.action_path, method: detailed_status.action_method,
+    title: "#{subject.name}: #{detailed_status.action_title}", class: 'ci-action-icon-container' do
+    %i.ci-action-icon-wrapper
+      = icon(detailed_status.action_icon, class: detailed_status.action_class)
diff --git a/app/views/ci/status/_icon_with_name.html.haml b/app/views/ci/status/_icon_with_name.html.haml
index a467316ef47..028e1fe9402 100644
--- a/app/views/ci/status/_icon_with_name.html.haml
+++ b/app/views/ci/status/_icon_with_name.html.haml
@@ -1,11 +1,10 @@
 - detailed_status = subject.detailed_status(current_user)
 - details_path = detailed_status.details_path if detailed_status.has_details?
 - klass = "ci-status-icon ci-status-icon-#{detailed_status}"
-- status_icon = graph ? "#{detailed_status.icon}_graph" : detailed_status.icon
 
 - if details_path
   = link_to details_path, class: klass, data: { toggle: 'tooltip', title: "#{subject.name} - #{detailed_status}" } do
-    %span{ class: klass }= custom_icon(status_icon)
+    %span{ class: klass }= custom_icon(detailed_status.icon)
     .ci-status-text= subject.name
 - else
   %span{ class: klass }= custom_icon(detailed_status.icon)
diff --git a/app/views/ci/status/_icon_with_name_and_action.html.haml b/app/views/ci/status/_icon_with_name_and_action.html.haml
index b912c212534..76db3b7f38a 100644
--- a/app/views/ci/status/_icon_with_name_and_action.html.haml
+++ b/app/views/ci/status/_icon_with_name_and_action.html.haml
@@ -1,4 +1,4 @@
-= render "ci/status/icon_with_name", subject: subject, graph: true
+= render "ci/status/icon_with_name", subject: subject
 
 - detailed_status = subject.detailed_status(current_user)
 - if detailed_status.has_action?
diff --git a/app/views/projects/stage/_graph.html.haml b/app/views/projects/stage/_graph.html.haml
index 745b6d143f4..255091cbfe8 100644
--- a/app/views/projects/stage/_graph.html.haml
+++ b/app/views/projects/stage/_graph.html.haml
@@ -14,7 +14,7 @@
           %li.build{ class: ("playable" if is_playable) }
             .curve
             .build-content
-              = render 'ci/status/icon_with_name_and_action', subject: status
+              = render 'ci/status/graph_icon_with_name_and_action', subject: status
         - else
           %li.build
             .curve
diff --git a/app/views/projects/stage/_in_stage_group.html.haml b/app/views/projects/stage/_in_stage_group.html.haml
index 5c9b6549b37..70101ccf806 100644
--- a/app/views/projects/stage/_in_stage_group.html.haml
+++ b/app/views/projects/stage/_in_stage_group.html.haml
@@ -10,4 +10,4 @@
   %ul
     - subject.each do |status|
       %li.dropdown-build
-        = render 'ci/status/icon_with_name_and_action', subject: status
+        = render 'ci/status/graph_icon_with_name_and_action', subject: status
diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb
index e21de05ac64..7358931b9f0 100644
--- a/spec/features/projects/pipelines/pipeline_spec.rb
+++ b/spec/features/projects/pipelines/pipeline_spec.rb
@@ -40,7 +40,7 @@ describe "Pipelines", feature: true, js: true do
 
     context 'pipeline graph' do
       it 'shows a running icon and a cancel action for the running build' do
-        page.within('.stage-column:first-child .build:first-child') do
+        page.within('.stage-column:nth-child(2) .build:first-child') do
           expect(page).to have_selector('.ci-status-icon-running')
           expect(page).to have_content('deploy')
           expect(page).to have_selector('.ci-action-icon-container .fa-ban')
@@ -56,7 +56,7 @@ describe "Pipelines", feature: true, js: true do
       end
 
       it 'shows the failed icon and a retry action for the failed build' do
-        page.within('.stage-column:nth-child(2) .build') do
+        page.within('.stage-column:first-child .build') do
           expect(page).to have_selector('.ci-status-icon-failed')
           expect(page).to have_content('test')
           expect(page).to have_selector('.ci-action-icon-container .fa-refresh')
@@ -64,7 +64,7 @@ describe "Pipelines", feature: true, js: true do
       end
 
       it 'shows the skipped icon and a play action for the manual build' do
-        page.within('.stage-column:first-child .build:nth-child(2)') do
+        page.within('.stage-column:nth-child(2) .build:nth-child(2)') do
           expect(page).to have_selector('.ci-status-icon-skipped')
           expect(page).to have_content('manual')
           expect(page).to have_selector('.ci-action-icon-container .ci-play-icon')
-- 
GitLab