Remove `Rails.env.test?` from production code

This commit is contained in:
Toon Claes 2018-04-19 16:56:36 +02:00
parent 6dca7b5b0d
commit b07c4e3dc4
2 changed files with 3 additions and 14 deletions

View File

@ -15,7 +15,7 @@ module RepositoryCheck
# check, only one (or two) will be checked at a time.
project_ids.each do |project_id|
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)
@ -47,16 +47,5 @@ module RepositoryCheck
timeout: 24.hours
).try_obtain
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

View File

@ -31,8 +31,8 @@ describe RepositoryCheck::BatchWorker do
it 'does nothing when repository checks are disabled' do
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)
end