From 6c80b597f58aaaca514e45a7e83b811db301e651 Mon Sep 17 00:00:00 2001
From: Lin Jen-Shin <godfat@godfat.org>
Date: Wed, 13 Jul 2016 21:44:27 +0800
Subject: [PATCH] Introduce path_from_ref and save some typing

---
 .../projects/artifacts_controller_spec.rb     | 26 ++++++-------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/spec/requests/projects/artifacts_controller_spec.rb b/spec/requests/projects/artifacts_controller_spec.rb
index 2ab1c1ac428..4c4bacfcbda 100644
--- a/spec/requests/projects/artifacts_controller_spec.rb
+++ b/spec/requests/projects/artifacts_controller_spec.rb
@@ -50,12 +50,12 @@ describe Projects::ArtifactsController do
     end
 
     context '302' do
-      def path_from_sha
+      def path_from_ref(ref = pipeline.sha, build_name = build.name)
         search_namespace_project_artifacts_path(
           project.namespace,
           project,
-          pipeline.sha,
-          build.name,
+          ref,
+          build_name,
           'browse')
       end
 
@@ -72,7 +72,7 @@ describe Projects::ArtifactsController do
 
       context 'with sha' do
         before do
-          get path_from_sha
+          get path_from_ref
         end
 
         it_behaves_like 'redirect to the build'
@@ -84,12 +84,7 @@ describe Projects::ArtifactsController do
         end
 
         before do
-          get search_namespace_project_artifacts_path(
-            project.namespace,
-            project,
-            'master',
-            build.name,
-            'browse')
+          get path_from_ref('master')
         end
 
         it_behaves_like 'redirect to the build'
@@ -101,12 +96,7 @@ describe Projects::ArtifactsController do
         end
 
         before do
-          get search_namespace_project_artifacts_path(
-            project.namespace,
-            project,
-            'improve/awesome',
-            build.name,
-            'browse')
+          get path_from_ref('improve/awesome')
         end
 
         it_behaves_like 'redirect to the build'
@@ -120,7 +110,7 @@ describe Projects::ArtifactsController do
         end
 
         before do
-          get path_from_sha
+          get path_from_ref
         end
 
         it_behaves_like 'redirect to the build'
@@ -133,7 +123,7 @@ describe Projects::ArtifactsController do
         end
 
         before do
-          get path_from_sha
+          get path_from_ref
         end
 
         it_behaves_like 'redirect to the build'
-- 
GitLab