Commit 6cb22fc9 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '342242-remove-calls-to-clean_frontend_fixtures' into 'master'

Remove the use of 'clean_frontend_fixtures'

See merge request gitlab-org/gitlab!71664
parents 7e6a8e02 993e93f9
......@@ -848,10 +848,6 @@ describe GraphQL::Query, type: :request do
all_releases_query_path = 'releases/graphql/queries/all_releases.query.graphql'
before(:all) do
clean_frontend_fixtures('graphql/releases/')
end
it "graphql/#{all_releases_query_path}.json" do
query = get_graphql_query_as_string(all_releases_query_path)
......
......@@ -12,10 +12,6 @@ RSpec.describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
freeze_time { example.run }
end
before(:all) do
clean_frontend_fixtures('analytics/charts/')
end
describe Groups::Analytics::TasksByTypeController, type: :controller do
render_views
......
......@@ -37,7 +37,6 @@ RSpec.describe 'DevOps Adoption (GraphQL fixtures)' do
end
before do
clean_frontend_fixtures('graphql/analytics/devops_report/devops_adoption/')
stub_licensed_features(instance_level_devops_adoption: true, group_level_devops_adoption: true)
end
......
......@@ -29,10 +29,6 @@ RSpec.describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
freeze_time { example.run }
end
before(:all) do
clean_frontend_fixtures('analytics/metrics')
end
describe Groups::Analytics::CycleAnalytics::SummaryController, type: :controller do
render_views
......
......@@ -16,11 +16,7 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
let(:group_wiki_page) { create(:wiki_page, wiki: group_wiki) }
let(:project_wiki_page) { create(:wiki_page, wiki: project_wiki) }
fixture_subdir = 'api/markdown'
before(:all) do
clean_frontend_fixtures(fixture_subdir)
group.add_owner(user)
end
......@@ -44,7 +40,7 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
name = "#{context}_#{name}" unless context.empty?
it "#{fixture_subdir}/#{name}.json" do
it "api/markdown/#{name}.json" do
api_url = case context
when 'group_wiki'
"/groups/#{group.full_path}/-/wikis/#{group_wiki_page.slug}/preview_markdown"
......
......@@ -44,10 +44,6 @@ RSpec.describe 'DORA Metrics (JavaScript fixtures)' do
}
end
before(:all) do
clean_frontend_fixtures('api/dora/metrics')
end
def make_request(additional_query_params:)
params = shared_params.merge(additional_query_params)
get api("/projects/#{project.id}/dora/metrics?#{params.to_query}", reporter)
......
......@@ -34,10 +34,6 @@ RSpec.describe 'Epics (JavaScript fixtures)' do
]
end
before(:all) do
clean_frontend_fixtures('epic/')
end
describe EpicPresenter, '(JavaScript fixtures)', type: :presenter do
let(:response) { @json_data.to_json }
......
......@@ -11,10 +11,6 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures in EE co
render_views
before(:all) do
clean_frontend_fixtures('ee/merge_requests/')
end
before do
sign_in(user)
end
......
......@@ -9,10 +9,6 @@ RSpec.describe Groups::SamlProvidersController, '(JavaScript fixtures)', type: :
render_views
before(:all) do
clean_frontend_fixtures('groups/saml_providers/')
end
before do
sign_in(user)
group.add_owner(user)
......
......@@ -9,10 +9,6 @@ RSpec.describe SearchController, '(JavaScript fixtures)', type: :controller do
let_it_be(:user) { create(:admin) }
before(:all) do
clean_frontend_fixtures('ee/search/')
end
before do
sign_in(user)
end
......
# frozen_string_literal: true
require 'yaml'
unless Rails.env.production?
namespace :frontend do
desc 'GitLab | Frontend | Generate fixtures for JavaScript tests'
RSpec::Core::RakeTask.new(:fixtures, [:pattern]) do |t, args|
require 'fileutils'
require_relative '../../spec/support/helpers/javascript_fixtures_helpers'
FileUtils.rm_r(JavaScriptFixturesHelpers.fixture_root_path, force: true)
directories = %w[spec]
directories << 'ee/spec' if Gitlab.ee?
directory_glob = "{#{directories.join(',')}}"
......@@ -16,6 +20,8 @@ unless Rails.env.production?
desc 'GitLab | Frontend | Generate fixtures for JavaScript integration tests'
RSpec::Core::RakeTask.new(:mock_server_rspec_fixtures) do |t, args|
require 'yaml'
base_path = Pathname.new('spec/frontend_integration/fixture_generators.yml')
ee_path = Pathname.new('ee') + base_path
......
......@@ -13,10 +13,6 @@ RSpec.describe Admin::AbuseReportsController, '(JavaScript fixtures)', type: :co
render_views
before(:all) do
clean_frontend_fixtures('abuse_reports/')
end
before do
sign_in(admin)
enable_admin_mode!(admin)
......
......@@ -17,10 +17,6 @@ RSpec.describe Admin::UsersController, '(JavaScript fixtures)', type: :controlle
render_views
before(:all) do
clean_frontend_fixtures('admin/users')
end
it 'admin/users/new_with_internal_user_regex.html' do
stub_application_setting(user_default_external: true)
stub_application_setting(user_default_internal_regex: '^(?:(?!\.ext@).)*$\r?')
......
......@@ -6,10 +6,6 @@ RSpec.describe 'Analytics (JavaScript fixtures)', :sidekiq_inline do
let_it_be(:value_stream_id) { 'default' }
before(:all) do
clean_frontend_fixtures('projects/analytics/value_stream_analytics/')
end
before do
update_metrics
create_deployment
......
......@@ -21,11 +21,7 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
let(:project_wiki_page) { create(:wiki_page, wiki: project_wiki) }
fixture_subdir = 'api/markdown'
before(:all) do
clean_frontend_fixtures(fixture_subdir)
group.add_owner(user)
project.add_maintainer(user)
end
......@@ -49,7 +45,7 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
name = "#{context}_#{name}" unless context.empty?
it "#{fixture_subdir}/#{name}.json" do
it "api/markdown/#{name}.json" do
api_url = case context
when 'project'
"/#{project.full_path}/preview_markdown"
......
......@@ -11,10 +11,6 @@ RSpec.describe API::MergeRequests, '(JavaScript fixtures)', type: :request do
let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'lorem-ipsum') }
let_it_be(:mr) { create(:merge_request, source_project: project) }
before(:all) do
clean_frontend_fixtures('api/merge_requests')
end
it 'api/merge_requests/get.json' do
4.times { |i| create(:merge_request, source_project: project, source_branch: "branch-#{i}") }
......
......@@ -11,10 +11,6 @@ RSpec.describe API::Projects, '(JavaScript fixtures)', type: :request do
let(:project) { create(:project, :repository, namespace: namespace, path: 'lorem-ipsum') }
let(:project_empty) { create(:project_empty_repo, namespace: namespace, path: 'lorem-ipsum-empty') }
before(:all) do
clean_frontend_fixtures('api/projects')
end
it 'api/projects/get.json' do
get api("/projects/#{project.id}", admin)
......
......@@ -19,10 +19,6 @@ RSpec.describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', ty
render_views
before(:all) do
clean_frontend_fixtures('application_settings/')
end
after do
remove_repository(project)
end
......
......@@ -11,10 +11,6 @@ RSpec.describe ::AutocompleteController, '(JavaScript fixtures)', type: :control
let(:project) { create(:project, namespace: group, path: 'autocomplete-project') }
let(:merge_request) { create(:merge_request, source_project: project, author: user) }
before(:all) do
clean_frontend_fixtures('autocomplete/')
end
before do
group.add_owner(user)
sign_in(user)
......
......@@ -10,10 +10,6 @@ RSpec.describe Projects::AutocompleteSourcesController, '(JavaScript fixtures)',
let_it_be(:project) { create(:project, namespace: group, path: 'autocomplete-sources-project') }
let_it_be(:issue) { create(:issue, project: project) }
before(:all) do
clean_frontend_fixtures('autocomplete_sources/')
end
before do
group.add_owner(user)
sign_in(user)
......
......@@ -11,10 +11,6 @@ RSpec.describe Projects::BlobController, '(JavaScript fixtures)', type: :control
render_views
before(:all) do
clean_frontend_fixtures('blob/')
end
before do
sign_in(user)
allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
......
......@@ -9,11 +9,6 @@ RSpec.describe 'Branches (JavaScript fixtures)' do
let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
let_it_be(:user) { project.owner }
before(:all) do
clean_frontend_fixtures('branches/')
clean_frontend_fixtures('api/branches/')
end
after(:all) do
remove_repository(project)
end
......
......@@ -12,10 +12,6 @@ RSpec.describe Projects::ClustersController, '(JavaScript fixtures)', type: :con
render_views
before(:all) do
clean_frontend_fixtures('clusters/')
end
before do
sign_in(user)
end
......
......@@ -9,11 +9,6 @@ RSpec.describe 'Commit (JavaScript fixtures)' do
let_it_be(:user) { project.owner }
let_it_be(:commit) { project.commit("master") }
before(:all) do
clean_frontend_fixtures('commit/')
clean_frontend_fixtures('api/commits/')
end
before do
allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
end
......
......@@ -13,10 +13,6 @@ RSpec.describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :c
let(:project3) { create(:project, :internal)}
let(:project4) { create(:project, :internal)}
before(:all) do
clean_frontend_fixtures('deploy_keys/')
end
before do
# Using an admin for these fixtures because they are used for verifying a frontend
# component that would normally get its data from `Admin::DeployKeysController`
......
......@@ -9,10 +9,6 @@ RSpec.describe 'Freeze Periods (JavaScript fixtures)' do
let_it_be(:project) { create(:project, :repository, path: 'freeze-periods-project') }
let_it_be(:user) { project.owner }
before(:all) do
clean_frontend_fixtures('api/freeze-periods/')
end
after(:all) do
remove_repository(project)
end
......
......@@ -8,10 +8,6 @@ RSpec.describe 'Groups (JavaScript fixtures)', type: :controller do
let(:user) { create(:user) }
let(:group) { create(:group, name: 'frontend-fixtures-group', runners_token: 'runnerstoken:intabulasreferre')}
before(:all) do
clean_frontend_fixtures('groups/')
end
before do
group.add_owner(user)
sign_in(user)
......
......@@ -11,10 +11,6 @@ RSpec.describe Projects::IssuesController, '(JavaScript fixtures)', type: :contr
render_views
before(:all) do
clean_frontend_fixtures('issues/')
end
before do
project.add_maintainer(user)
sign_in(user)
......
......@@ -21,10 +21,6 @@ RSpec.describe Projects::JobsController, '(JavaScript fixtures)', type: :control
render_views
before(:all) do
clean_frontend_fixtures('jobs/')
end
before do
sign_in(user)
end
......
......@@ -17,10 +17,6 @@ RSpec.describe 'Labels (JavaScript fixtures)' do
let!(:groub_label_space) { create(:group_label, group: group, title: 'some space', color: '#FFFFFF') }
let!(:groub_label_violets) { create(:group_label, group: group, title: 'violets', color: '#0000FF') }
before(:all) do
clean_frontend_fixtures('labels/')
end
after do
remove_repository(project)
end
......
......@@ -49,10 +49,6 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type:
render_views
before(:all) do
clean_frontend_fixtures('merge_requests/')
end
before do
sign_in(user)
allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
......
......@@ -20,10 +20,6 @@ RSpec.describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)'
render_views
before(:all) do
clean_frontend_fixtures('merge_request_diffs/')
end
before do
# Create a user that matches the project.commit author
# This is so that the "author" information will be populated
......
......@@ -12,10 +12,6 @@ RSpec.describe MetricsDashboard, '(JavaScript fixtures)', type: :controller do
let_it_be(:environment) { create(:environment, id: 1, project: project) }
let_it_be(:params) { { environment: environment } }
before(:all) do
clean_frontend_fixtures('metrics_dashboard/')
end
controller(::ApplicationController) do
include MetricsDashboard
end
......
......@@ -15,10 +15,6 @@ RSpec.describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', t
render_views
before(:all) do
clean_frontend_fixtures('pipeline_schedules/')
end
before do
sign_in(user)
end
......
......@@ -23,10 +23,6 @@ RSpec.describe Projects::PipelinesController, '(JavaScript fixtures)', type: :co
let!(:build_test) { create(:ci_build, pipeline: pipeline, stage: 'test') }
let!(:build_deploy_failed) { create(:ci_build, status: :failed, pipeline: pipeline, stage: 'deploy') }
before(:all) do
clean_frontend_fixtures('pipelines/')
end
before do
sign_in(user)
end
......
......@@ -16,10 +16,6 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do
render_views
before(:all) do
clean_frontend_fixtures('projects/')
end
before do
project_with_repo.add_maintainer(user)
sign_in(user)
......@@ -57,10 +53,6 @@ RSpec.describe 'Projects (JavaScript fixtures)', type: :controller do
project_variable_populated.add_maintainer(user)
end
before(:all) do
clean_frontend_fixtures('graphql/projects/access_tokens')
end
base_input_path = 'access_tokens/graphql/queries/'
base_output_path = 'graphql/projects/access_tokens/'
query_name = 'get_projects.query.graphql'
......
......@@ -8,10 +8,6 @@ RSpec.describe 'Projects JSON endpoints (JavaScript fixtures)', type: :controlle
let(:admin) { create(:admin, name: 'root') }
let(:project) { create(:project, :repository) }
before(:all) do
clean_frontend_fixtures('projects_json/')
end
before do
project.add_maintainer(admin)
sign_in(admin)
......
......@@ -12,10 +12,6 @@ RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :con
render_views
before(:all) do
clean_frontend_fixtures('services/prometheus')
end
before do
sign_in(user)
end
......
......@@ -9,14 +9,6 @@ RSpec.describe 'Raw files', '(JavaScript fixtures)' do
let(:project) { create(:project, :repository, namespace: namespace, path: 'raw-project') }
let(:response) { @blob.data.force_encoding('UTF-8') }
before(:all) do
clean_frontend_fixtures('blob/notebook/')
clean_frontend_fixtures('blob/pdf/')
clean_frontend_fixtures('blob/text/')
clean_frontend_fixtures('blob/binary/')
clean_frontend_fixtures('blob/images/')
end
after do
remove_repository(project)
end
......
......@@ -116,10 +116,6 @@ RSpec.describe 'Releases (JavaScript fixtures)' do
end
describe API::Releases, type: :request do
before(:all) do
clean_frontend_fixtures('api/releases/')
end
it 'api/releases/release.json' do
get api("/projects/#{project.id}/releases/#{release.tag}", admin)
......@@ -134,10 +130,6 @@ RSpec.describe 'Releases (JavaScript fixtures)' do
one_release_query_path = 'releases/graphql/queries/one_release.query.graphql'
one_release_for_editing_query_path = 'releases/graphql/queries/one_release_for_editing.query.graphql'
before(:all) do
clean_frontend_fixtures('graphql/releases/')
end
it "graphql/#{all_releases_query_path}.json" do
query = get_graphql_query_as_string(all_releases_query_path)
......
......@@ -20,10 +20,6 @@ RSpec.describe 'Runner (JavaScript fixtures)' do
query_path = 'runner/graphql/'
fixtures_path = 'graphql/runner/'
before(:all) do
clean_frontend_fixtures(fixtures_path)
end
after(:all) do
remove_repository(project)
end
......
......@@ -9,10 +9,6 @@ RSpec.describe SearchController, '(JavaScript fixtures)', type: :controller do
let_it_be(:user) { create(:user) }
before(:all) do
clean_frontend_fixtures('search/')
end
before do
sign_in(user)
end
......
......@@ -12,10 +12,6 @@ RSpec.describe Projects::ServicesController, '(JavaScript fixtures)', type: :con
render_views
before(:all) do
clean_frontend_fixtures('services/')
end
before do
sign_in(user)
end
......
......@@ -5,10 +5,6 @@ require 'spec_helper'
RSpec.describe 'Sessions (JavaScript fixtures)' do
include JavaScriptFixturesHelpers
before(:all) do
clean_frontend_fixtures('sessions/')
end
describe SessionsController, '(JavaScript fixtures)', type: :controller do
include DeviseHelpers
......
......@@ -12,10 +12,6 @@ RSpec.describe SnippetsController, '(JavaScript fixtures)', type: :controller do
render_views
before(:all) do
clean_frontend_fixtures('snippets/')
end
before do
sign_in(user)
allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
......
......@@ -9,10 +9,6 @@ RSpec.describe 'Startup CSS fixtures', type: :controller do
render_views
before(:all) do
clean_frontend_fixtures('startup_css/')
end
shared_examples 'startup css project fixtures' do |type|
let(:user) { create(:user, :admin) }
let(:project) { create(:project, :public, :repository, description: 'Code and stuff', creator: user) }
......
......@@ -8,10 +8,6 @@ RSpec.describe 'Tags (JavaScript fixtures)' do
let_it_be(:project) { create(:project, :repository, path: 'tags-project') }
let_it_be(:user) { project.owner }
before(:all) do
clean_frontend_fixtures('api/tags/')
end
after(:all) do
remove_repository(project)
end
......
......@@ -8,10 +8,6 @@ RSpec.describe TimeZoneHelper, '(JavaScript fixtures)' do
let(:response) { @timezones.sort_by! { |tz| tz[:name] }.to_json }
before(:all) do
clean_frontend_fixtures('timezones/')
end
it 'timezones/short.json' do
@timezones = timezone_data(format: :short)
end
......
......@@ -13,10 +13,6 @@ RSpec.describe 'Todos (JavaScript fixtures)' do
let(:issue_2) { create(:issue, title: 'issue_2', project: project) }
let!(:todo_2) { create(:todo, :done, user: user, project: project, target: issue_2, created_at: 50.hours.ago) }
before(:all) do
clean_frontend_fixtures('todos/')
end
after do
remove_repository(project)
end
......
......@@ -7,10 +7,6 @@ RSpec.context 'U2F' do
let(:user) { create(:user, :two_factor_via_u2f, otp_secret: 'otpsecret:coolkids') }
before(:all) do
clean_frontend_fixtures('u2f/')
end
before do
stub_feature_flags(webauthn: false)
end
......
......@@ -7,10 +7,6 @@ RSpec.context 'WebAuthn' do
let(:user) { create(:user, :two_factor_via_webauthn, otp_secret: 'otpsecret:coolkids') }
before(:all) do
clean_frontend_fixtures('webauthn/')
end
describe SessionsController, '(JavaScript fixtures)', type: :controller do
include DeviseHelpers
......
......@@ -3,6 +3,8 @@
require 'action_dispatch/testing/test_request'
require 'fileutils'
require_relative '../../../lib/gitlab/popen'
module JavaScriptFixturesHelpers
extend ActiveSupport::Concern
include Gitlab::Popen
......@@ -25,15 +27,6 @@ module JavaScriptFixturesHelpers
'tmp/tests/frontend/fixtures' + (Gitlab.ee? ? '-ee' : '')
end
# Public: Removes all fixture files from given directory
#
# directory_name - directory of the fixtures (relative to .fixture_root_path)
#
# TODO: Make sure this isn't called anymore.
def clean_frontend_fixtures(directory_name)
# We don't really need to cleanup fixtures, as this can be a problem when FOSS & EE fixtures try to generate files in the same folder.
end
def remove_repository(project)
Gitlab::Shell.new.remove_repository(project.repository_storage, project.disk_path)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment