Commit a882026b authored by Gabriel Mazetto's avatar Gabriel Mazetto

Cleaning up repositories for javascript fixture specs to work correctly

We need to cleanup after each execution so we can still re-use the same
paths and prevent collision with the on disk validation
parent 8f178c42
...@@ -115,7 +115,7 @@ module Projects ...@@ -115,7 +115,7 @@ module Projects
Project.transaction do Project.transaction do
@project.create_or_update_import_data(data: import_data[:data], credentials: import_data[:credentials]) if import_data @project.create_or_update_import_data(data: import_data[:data], credentials: import_data[:credentials]) if import_data
if @project.valid? && @project.save && !@project.import? if @project.save && !@project.import?
raise 'Failed to create repository' unless @project.create_repository raise 'Failed to create repository' unless @project.create_repository
end end
end end
......
...@@ -17,6 +17,10 @@ describe Projects::BlobController, '(JavaScript fixtures)', type: :controller do ...@@ -17,6 +17,10 @@ describe Projects::BlobController, '(JavaScript fixtures)', type: :controller do
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'blob/show.html.raw' do |example| it 'blob/show.html.raw' do |example|
get(:show, get(:show,
namespace_id: project.namespace, namespace_id: project.namespace,
......
...@@ -17,6 +17,10 @@ describe Projects::BranchesController, '(JavaScript fixtures)', type: :controlle ...@@ -17,6 +17,10 @@ describe Projects::BranchesController, '(JavaScript fixtures)', type: :controlle
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'branches/new_branch.html.raw' do |example| it 'branches/new_branch.html.raw' do |example|
get :new, get :new,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
......
...@@ -17,6 +17,10 @@ describe Dashboard::ProjectsController, '(JavaScript fixtures)', type: :controll ...@@ -17,6 +17,10 @@ describe Dashboard::ProjectsController, '(JavaScript fixtures)', type: :controll
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'dashboard/user-callout.html.raw' do |example| it 'dashboard/user-callout.html.raw' do |example|
rendered = render_template('shared/_user_callout') rendered = render_template('shared/_user_callout')
store_frontend_fixture(rendered, example.description) store_frontend_fixture(rendered, example.description)
......
...@@ -16,6 +16,10 @@ describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :control ...@@ -16,6 +16,10 @@ describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :control
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
render_views render_views
it 'deploy_keys/keys.json' do |example| it 'deploy_keys/keys.json' do |example|
......
...@@ -17,6 +17,10 @@ describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller ...@@ -17,6 +17,10 @@ describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'issues/open-issue.html.raw' do |example| it 'issues/open-issue.html.raw' do |example|
render_issue(example.description, create(:issue, project: project)) render_issue(example.description, create(:issue, project: project))
end end
......
...@@ -21,6 +21,10 @@ describe Projects::JobsController, '(JavaScript fixtures)', type: :controller do ...@@ -21,6 +21,10 @@ describe Projects::JobsController, '(JavaScript fixtures)', type: :controller do
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'builds/build-with-artifacts.html.raw' do |example| it 'builds/build-with-artifacts.html.raw' do |example|
get :show, get :show,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
......
...@@ -19,6 +19,10 @@ describe 'Labels (JavaScript fixtures)' do ...@@ -19,6 +19,10 @@ describe 'Labels (JavaScript fixtures)' do
clean_frontend_fixtures('labels/') clean_frontend_fixtures('labels/')
end end
after do
remove_repository(project)
end
describe Groups::LabelsController, '(JavaScript fixtures)', type: :controller do describe Groups::LabelsController, '(JavaScript fixtures)', type: :controller do
render_views render_views
......
...@@ -37,6 +37,10 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont ...@@ -37,6 +37,10 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'merge_requests/merge_request_with_task_list.html.raw' do |example| it 'merge_requests/merge_request_with_task_list.html.raw' do |example|
create(:ci_build, :pending, pipeline: pipeline) create(:ci_build, :pending, pipeline: pipeline)
......
...@@ -29,6 +29,10 @@ describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type ...@@ -29,6 +29,10 @@ describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'merge_request_diffs/inline_changes_tab_with_comments.json' do |example| it 'merge_request_diffs/inline_changes_tab_with_comments.json' do |example|
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request)
create(:note_on_merge_request, author: admin, project: project, noteable: merge_request) create(:note_on_merge_request, author: admin, project: project, noteable: merge_request)
......
...@@ -17,6 +17,10 @@ describe ProjectsController, '(JavaScript fixtures)', type: :controller do ...@@ -17,6 +17,10 @@ describe ProjectsController, '(JavaScript fixtures)', type: :controller do
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'projects/dashboard.html.raw' do |example| it 'projects/dashboard.html.raw' do |example|
get :show, get :show,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
......
...@@ -18,6 +18,10 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle ...@@ -18,6 +18,10 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'services/prometheus/prometheus_service.html.raw' do |example| it 'services/prometheus/prometheus_service.html.raw' do |example|
get :edit, get :edit,
namespace_id: namespace, namespace_id: namespace,
......
...@@ -10,6 +10,10 @@ describe 'Raw files', '(JavaScript fixtures)', type: :controller do ...@@ -10,6 +10,10 @@ describe 'Raw files', '(JavaScript fixtures)', type: :controller do
clean_frontend_fixtures('blob/notebook/') clean_frontend_fixtures('blob/notebook/')
end end
after do
remove_repository(project)
end
it 'blob/notebook/basic.json' do |example| it 'blob/notebook/basic.json' do |example|
blob = project.repository.blob_at('6d85bb69', 'files/ipython/basic.ipynb') blob = project.repository.blob_at('6d85bb69', 'files/ipython/basic.ipynb')
......
...@@ -18,6 +18,10 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle ...@@ -18,6 +18,10 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'services/edit_service.html.raw' do |example| it 'services/edit_service.html.raw' do |example|
get :edit, get :edit,
namespace_id: namespace, namespace_id: namespace,
......
...@@ -18,6 +18,10 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do ...@@ -18,6 +18,10 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do
sign_in(admin) sign_in(admin)
end end
after do
remove_repository(project)
end
it 'snippets/show.html.raw' do |example| it 'snippets/show.html.raw' do |example|
get(:show, id: snippet.to_param) get(:show, id: snippet.to_param)
......
...@@ -15,6 +15,10 @@ describe 'Todos (JavaScript fixtures)' do ...@@ -15,6 +15,10 @@ describe 'Todos (JavaScript fixtures)' do
clean_frontend_fixtures('todos/') clean_frontend_fixtures('todos/')
end end
after do
remove_repository(project)
end
describe Dashboard::TodosController, '(JavaScript fixtures)', type: :controller do describe Dashboard::TodosController, '(JavaScript fixtures)', type: :controller do
render_views render_views
......
...@@ -31,6 +31,10 @@ module JavaScriptFixturesHelpers ...@@ -31,6 +31,10 @@ module JavaScriptFixturesHelpers
File.write(fixture_file_name, fixture) File.write(fixture_file_name, fixture)
end end
def remove_repository(project)
Gitlab::Shell.new.remove_repository(project.repository_storage_path, project.disk_path)
end
private private
# Private: Prepare a response object for use as a frontend fixture # Private: Prepare a response object for use as a frontend fixture
......
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