From bd7c52c734bd25b4b2549baf35b2957b45c7a972 Mon Sep 17 00:00:00 2001
From: Grzegorz Bizon <grzegorz.bizon@ntsn.pl>
Date: Mon, 1 Feb 2016 14:30:05 +0100
Subject: [PATCH] Add feature specs for build erase button

---
 features/project/builds/summary.feature  |  7 +++++++
 features/steps/project/builds/summary.rb | 14 ++++++++++++++
 features/steps/shared/builds.rb          |  4 ++++
 3 files changed, 25 insertions(+)

diff --git a/features/project/builds/summary.feature b/features/project/builds/summary.feature
index b69d279517b..b4fb537f3d8 100644
--- a/features/project/builds/summary.feature
+++ b/features/project/builds/summary.feature
@@ -13,3 +13,10 @@ Feature: Project Builds Summary
   Scenario: I browse project builds page
     When I visit project builds page
     Then I see button to CI Lint
+
+  Scenario: I erase a build
+    Given recent build has a build trace
+    When I visit recent build details page
+    And I click erase build button
+    Then recent build has been erased
+    And recent build summary does not have artifacts widget
diff --git a/features/steps/project/builds/summary.rb b/features/steps/project/builds/summary.rb
index 4f94fc96354..70de61101b8 100644
--- a/features/steps/project/builds/summary.rb
+++ b/features/steps/project/builds/summary.rb
@@ -10,4 +10,18 @@ class Spinach::Features::ProjectBuildsSummary < Spinach::FeatureSteps
       expect(ci_lint_tool_link[:href]).to eq ci_lint_path
     end
   end
+
+  step 'I click erase build button' do
+    click_link 'Erase'
+  end
+
+  step 'recent build has been erased' do
+    expect(@build.artifacts_file.exists?).to be_falsy
+    expect(@build.artifacts_metadata.exists?).to be_falsy
+    expect(File.zero?(@build.path_to_trace)).to be true
+  end
+
+  step 'recent build summary does not have artifacts widget' do
+    expect(page).to have_no_css('.artifacts')
+  end
 end
diff --git a/features/steps/shared/builds.rb b/features/steps/shared/builds.rb
index fa54c93df0f..0bd5d93b997 100644
--- a/features/steps/shared/builds.rb
+++ b/features/steps/shared/builds.rb
@@ -42,6 +42,10 @@ module SharedBuilds
     @build.update_attributes(artifacts_metadata: gzip)
   end
 
+  step 'recent build has a build trace' do
+    @build.trace = 'build trace'
+  end
+
   step 'download of build artifacts archive starts' do
     expect(page.response_headers['Content-Type']).to eq 'application/zip'
     expect(page.response_headers['Content-Transfer-Encoding']).to eq 'binary'
-- 
GitLab