Skip to content
Snippets Groups Projects
Commit 31d0feea authored by Rubén Dávila's avatar Rubén Dávila
Browse files

Delete ProjectImportData record only if Project is not a mirror.

This fix ensure we always use the full import URL when syncing the
mirror.
parent 6a56cff6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -405,7 +405,7 @@ class Project < ActiveRecord::Base
 
ProjectCacheWorker.perform_async(self.id)
 
self.import_data.destroy if self.import_data
self.import_data.destroy if !mirror? && import_data
end
 
def import_url=(value)
Loading
Loading
Loading
Loading
@@ -812,4 +812,27 @@ describe Project, models: true do
expect(project.protected_branch?('foo')).to eq(false)
end
end
describe 'handling import URL' do
context 'when project is a mirror' do
it 'returns the full URL' do
project = create(:project, :mirror, import_url: 'http://user:pass@test.com')
project.import_finish
expect(project.reload.import_url).to eq('http://user:pass@test.com')
end
end
context 'when project is not a mirror' do
it 'returns the sanitized URL' do
project = create(:project, import_status: 'started', import_url: 'http://user:pass@test.com')
project.import_finish
expect(project.reload.import_url).to eq('http://test.com')
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment