Commit 1fc1c63e authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'check_if_repository_exists_before_creation' into 'master'

Don't record the exception when the repostory already exists

See merge request gitlab-org/gitlab!80090
parents 1370b083 2219fe6d
......@@ -23,7 +23,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
feature_category :source_code_management
def create
@project.create_repository
@project.create_repository unless @project.repository_exists?
redirect_to project_path(@project)
end
......
......@@ -3,7 +3,37 @@
require "spec_helper"
RSpec.describe Projects::RepositoriesController do
let(:project) { create(:project, :repository) }
let_it_be(:project) { create(:project, :repository) }
describe 'POST create' do
let_it_be(:user) { create(:user) }
let(:request) { post :create, params: { namespace_id: project.namespace, project_id: project } }
before do
project.add_maintainer(user)
sign_in(user)
end
context 'when repository does not exist' do
let!(:project) { create(:project) }
it 'creates the repository' do
expect { request }.to change { project.repository.raw_repository.exists? }.from(false).to(true)
expect(response).to be_redirect
end
end
context 'when repository already exists' do
it 'does not raise an exception' do
expect(Gitlab::ErrorTracking).not_to receive(:track_exception)
request
expect(response).to be_redirect
end
end
end
describe "GET archive" do
before do
......
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