From fef492a90107124da947cf94bd76bc8b7cc29169 Mon Sep 17 00:00:00 2001
From: Darby Frey <darbyfrey@gmail.com>
Date: Tue, 2 Aug 2022 14:04:38 -0500
Subject: [PATCH] Remove unused rails view for Secure Files UI

---
 .../projects/ci/secure_files/show/index.js    |  3 -
 .../projects/ci/secure_files_controller.rb    | 11 ---
 .../projects/ci/secure_files/show.html.haml   |  3 -
 config/routes/project.rb                      |  1 -
 .../ci/secure_files_controller_spec.rb        | 67 -------------------
 .../features/projects/ci/secure_files_spec.rb | 61 -----------------
 spec/routing/project_routing_spec.rb          |  6 --
 7 files changed, 152 deletions(-)
 delete mode 100644 app/assets/javascripts/pages/projects/ci/secure_files/show/index.js
 delete mode 100644 app/controllers/projects/ci/secure_files_controller.rb
 delete mode 100644 app/views/projects/ci/secure_files/show.html.haml
 delete mode 100644 spec/controllers/projects/ci/secure_files_controller_spec.rb
 delete mode 100644 spec/features/projects/ci/secure_files_spec.rb

diff --git a/app/assets/javascripts/pages/projects/ci/secure_files/show/index.js b/app/assets/javascripts/pages/projects/ci/secure_files/show/index.js
deleted file mode 100644
index 614866066653c..0000000000000
--- a/app/assets/javascripts/pages/projects/ci/secure_files/show/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import { initCiSecureFiles } from '~/ci_secure_files';
-
-initCiSecureFiles();
diff --git a/app/controllers/projects/ci/secure_files_controller.rb b/app/controllers/projects/ci/secure_files_controller.rb
deleted file mode 100644
index 59ddca19081bb..0000000000000
--- a/app/controllers/projects/ci/secure_files_controller.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-class Projects::Ci::SecureFilesController < Projects::ApplicationController
-  before_action :authorize_read_secure_files!
-
-  feature_category :pipeline_authoring
-
-  def show
-    render_404 unless Feature.enabled?(:ci_secure_files, project)
-  end
-end
diff --git a/app/views/projects/ci/secure_files/show.html.haml b/app/views/projects/ci/secure_files/show.html.haml
deleted file mode 100644
index 1a87ccd753c39..0000000000000
--- a/app/views/projects/ci/secure_files/show.html.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-- page_title s_('Secure Files')
-
-#js-ci-secure-files{ data: { project_id: @project.id, admin: can?(current_user, :admin_secure_files, @project).to_s, file_size_limit: Ci::SecureFile::FILE_SIZE_LIMIT.to_mb } }
diff --git a/config/routes/project.rb b/config/routes/project.rb
index 628fa3ad37bb7..d22029b605519 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -96,7 +96,6 @@
         namespace :ci do
           resource :lint, only: [:show, :create]
           resource :pipeline_editor, only: [:show], controller: :pipeline_editor, path: 'editor'
-          resource :secure_files, only: [:show], controller: :secure_files, path: 'secure_files'
           resources :daily_build_group_report_results, only: [:index], constraints: { format: /(csv|json)/ }
           namespace :prometheus_metrics do
             resources :histograms, only: [:create], constraints: { format: 'json' }
diff --git a/spec/controllers/projects/ci/secure_files_controller_spec.rb b/spec/controllers/projects/ci/secure_files_controller_spec.rb
deleted file mode 100644
index 200997e31b98d..0000000000000
--- a/spec/controllers/projects/ci/secure_files_controller_spec.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Projects::Ci::SecureFilesController do
-  let_it_be(:project) { create(:project) }
-  let_it_be(:user) { create(:user) }
-
-  subject(:show_request) { get :show, params: { namespace_id: project.namespace, project_id: project } }
-
-  describe 'GET #show' do
-    context 'when the :ci_secure_files feature flag is enabled' do
-      context 'with enough privileges' do
-        before do
-          stub_feature_flags(ci_secure_files: true)
-          sign_in(user)
-          project.add_developer(user)
-          show_request
-        end
-
-        it { expect(response).to have_gitlab_http_status(:ok) }
-
-        it 'renders show page' do
-          expect(response).to render_template :show
-        end
-      end
-    end
-
-    context 'when the :ci_secure_files feature flag is disabled' do
-      context 'with enough privileges' do
-        before do
-          stub_feature_flags(ci_secure_files: false)
-          sign_in(user)
-          project.add_developer(user)
-          show_request
-        end
-
-        it 'responds with 404' do
-          expect(response).to have_gitlab_http_status(:not_found)
-        end
-      end
-    end
-
-    context 'without enough privileges' do
-      before do
-        sign_in(user)
-        project.add_reporter(user)
-        show_request
-      end
-
-      it 'responds with 404' do
-        expect(response).to have_gitlab_http_status(:not_found)
-      end
-    end
-
-    context 'an unauthenticated user' do
-      before do
-        show_request
-      end
-
-      it 'redirects to sign in' do
-        expect(response).to have_gitlab_http_status(:found)
-        expect(response).to redirect_to('/users/sign_in')
-      end
-    end
-  end
-end
diff --git a/spec/features/projects/ci/secure_files_spec.rb b/spec/features/projects/ci/secure_files_spec.rb
deleted file mode 100644
index 412330eb5d622..0000000000000
--- a/spec/features/projects/ci/secure_files_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe 'Secure Files', :js do
-  let(:project) { create(:project) }
-  let(:user) { create(:user) }
-
-  before do
-    stub_feature_flags(ci_secure_files_read_only: false)
-    project.add_maintainer(user)
-    sign_in(user)
-  end
-
-  it 'user sees the Secure Files list component' do
-    visit project_ci_secure_files_path(project)
-    expect(page).to have_content('There are no secure files yet.')
-  end
-
-  it 'prompts the user to confirm before deleting a file' do
-    file = create(:ci_secure_file, project: project)
-
-    visit project_ci_secure_files_path(project)
-
-    expect(page).to have_content(file.name)
-
-    find('button.btn-danger').click
-
-    expect(page).to have_content("Delete #{file.name}?")
-
-    click_on('Delete secure file')
-
-    visit project_ci_secure_files_path(project)
-
-    expect(page).not_to have_content(file.name)
-  end
-
-  it 'displays an uploaded file in the file list' do
-    visit project_ci_secure_files_path(project)
-    expect(page).to have_content('There are no secure files yet.')
-
-    page.attach_file('spec/fixtures/ci_secure_files/upload-keystore.jks') do
-      click_button 'Upload File'
-    end
-
-    expect(page).to have_content('upload-keystore.jks')
-  end
-
-  it 'displays an error when a duplicate file upload is attempted' do
-    create(:ci_secure_file, project: project, name: 'upload-keystore.jks')
-    visit project_ci_secure_files_path(project)
-
-    expect(page).to have_content('upload-keystore.jks')
-
-    page.attach_file('spec/fixtures/ci_secure_files/upload-keystore.jks') do
-      click_button 'Upload File'
-    end
-
-    expect(page).to have_content('A file with this name already exists.')
-  end
-end
diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb
index 1d58a31bd6ee9..5d560620b8587 100644
--- a/spec/routing/project_routing_spec.rb
+++ b/spec/routing/project_routing_spec.rb
@@ -953,12 +953,6 @@ def show_with_template_type(template_type)
     end
   end
 
-  describe Projects::Ci::SecureFilesController, 'routing' do
-    it 'to #show' do
-      expect(get('/gitlab/gitlabhq/-/ci/secure_files')).to route_to('projects/ci/secure_files#show', namespace_id: 'gitlab', project_id: 'gitlabhq')
-    end
-  end
-
   context 'with a non-existent project' do
     it 'routes to 404 with get request' do
       expect(get: "/gitlab/not_exist").to route_to(
-- 
GitLab