Skip to content

Commit f6796b0

Browse files
authored
Check rails environment in #able_to_auto_remediate?. If prodcution return false. This turns off the remediation feature in production. (#1844)
1 parent 609f645 commit f6796b0

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

app/services/auto_remediate_service.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ def call
1818
end
1919

2020
def able_to_auto_remediate?
21+
# The following line can be removed when
22+
# auto-remediation is enabled in production
23+
return false if Rails.env.production?
24+
2125
work_version.latest_published_version? &&
2226
work_version.auto_remediation_started_at.nil? &&
2327
!work_version.auto_remediated_version &&

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ x-web_env: &web_env
77
REDIS_PASSWORD: redispassword
88
OAUTH_APP_ID: ${OAUTH_APP_ID}
99
OAUTH_APP_SECRET: ${OAUTH_APP_SECRET}
10-
DEFAULT_URL_HOST: web
10+
DEFAULT_URL_HOST: ${DEFAULT_URL_HOST:-web}
1111
SELENIUM_URL: http://selenium:4444/wd/hub
1212
APP_HOST: web
1313
OAUTH_APP_URL: ${OAUTH_APP_URL}

spec/services/auto_remediate_service_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@
2222
end
2323

2424
describe '#able_to_auto_remediate?' do
25+
# The following context block can be removed when
26+
# auto-remediation is enabled in production
27+
context 'when production environment' do
28+
before do
29+
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('production'))
30+
end
31+
32+
it 'returns false' do
33+
work_version = create(:work_version, :published)
34+
expect(described_class.new(work_version.id, false, true).able_to_auto_remediate?).to be false
35+
end
36+
end
37+
2538
context 'when the work version is the latest published version' do
2639
context 'when remediation has not been started' do
2740
context 'when there is no remediated version' do

0 commit comments

Comments
 (0)