Commit 89af3d15 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix/mirror-update-error' into 'master'

Fix 500 error updating mirror URLs for projects

Updating the mirror URL with an empty URL should just render the mirror page with the flash message stating that the URL can't be blank. At the moment we throw an error 500 if the old URL had some import data.

Fixes https://gitlab.com/gitlab-org/gitlab-ee/issues/1082

See merge request !780
parents c86ef86c 9dfa6315
Please view this file on the master branch, on stable branches it's out of date.
v 8.13.0 (unreleased)
- Fix 500 error updating mirror URLs for projects
v 8.12.4 (unreleased)
- [ES] Indexer works with smaller batches of repositories to not exceed NOFILE limit
......
......@@ -527,7 +527,7 @@ class Project < ActiveRecord::Base
end
def import_url
if import_data && super
if import_data && super.present?
import_url = Gitlab::UrlSanitizer.new(super, credentials: import_data.credentials)
import_url.full_url
else
......
require 'spec_helper'
describe Projects::MirrorsController do
let(:project) do
create(:project,
mirror: true,
mirror_user: user,
import_url: 'http://user:pass@test.url')
end
let(:user) { create(:user) }
describe 'updates the mirror URL' do
before do
project.team << [user, :master]
login_as(user)
end
it 'complains about passing an empty URL' do
patch namespace_project_mirror_path(project.namespace, project),
project: {
mirror: '1',
import_url: '',
mirror_user_id: '1',
mirror_trigger_builds: '0'
}
expect(response).to have_http_status :success
expect(response).to render_template(:show)
expect(response.body).to include('Import url can&#39;t be blank')
end
end
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