Remove `Rails.env.test?` from production code
This commit is contained in:
parent
6dca7b5b0d
commit
b07c4e3dc4
|
@ -15,7 +15,7 @@ module RepositoryCheck
|
||||||
# check, only one (or two) will be checked at a time.
|
# check, only one (or two) will be checked at a time.
|
||||||
project_ids.each do |project_id|
|
project_ids.each do |project_id|
|
||||||
break if Time.now - start >= RUN_TIME
|
break if Time.now - start >= RUN_TIME
|
||||||
break unless current_settings.repository_checks_enabled
|
break unless Gitlab::CurrentSettings.repository_checks_enabled
|
||||||
|
|
||||||
next unless try_obtain_lease(project_id)
|
next unless try_obtain_lease(project_id)
|
||||||
|
|
||||||
|
@ -47,16 +47,5 @@ module RepositoryCheck
|
||||||
timeout: 24.hours
|
timeout: 24.hours
|
||||||
).try_obtain
|
).try_obtain
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_settings
|
|
||||||
# No caching of the settings! If we cache them and an admin disables
|
|
||||||
# this feature, an active RepositoryCheckWorker would keep going for up
|
|
||||||
# to 1 hour after the feature was disabled.
|
|
||||||
if Rails.env.test?
|
|
||||||
Gitlab::CurrentSettings.fake_application_settings
|
|
||||||
else
|
|
||||||
ApplicationSetting.current
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,8 +31,8 @@ describe RepositoryCheck::BatchWorker do
|
||||||
|
|
||||||
it 'does nothing when repository checks are disabled' do
|
it 'does nothing when repository checks are disabled' do
|
||||||
create(:project, created_at: 1.week.ago)
|
create(:project, created_at: 1.week.ago)
|
||||||
current_settings = double('settings', repository_checks_enabled: false)
|
|
||||||
expect(subject).to receive(:current_settings) { current_settings }
|
stub_application_setting(repository_checks_enabled: false)
|
||||||
|
|
||||||
expect(subject.perform).to eq(nil)
|
expect(subject.perform).to eq(nil)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue