Commit 9a80b5fc authored by Valery Sizov's avatar Valery Sizov

Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ee into ce-upstream

parents ca9b7ab3 ad0f8f12
......@@ -269,7 +269,7 @@ class Project < ActiveRecord::Base
state :failed
after_transition any => :started, do: :schedule_add_import_job
after_transition any => :finished, do: :clear_import_data
after_transition any => :finished, do: :reset_cache_and_import_attrs
after_transition started: :finished do |project, transaction|
if project.mirror?
......@@ -453,12 +453,12 @@ class Project < ActiveRecord::Base
end
end
def clear_import_data
def reset_cache_and_import_attrs
update(import_error: nil)
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)
......
......@@ -895,6 +895,29 @@ describe Project, models: true do
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
describe '#protected_branch?' do
let(:project) { create(:empty_project) }
......@@ -908,4 +931,5 @@ describe Project, models: true do
expect(project.protected_branch?('foo')).to eq(false)
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