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