chore: Add climate-control gem for handling the test ENV vars (#3267)

This commit is contained in:
Akhil G Krishnan 2021-10-25 13:13:25 +05:30 committed by GitHub
parent 06289b03ea
commit 84df9c807d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 85 additions and 81 deletions

View file

@ -10,11 +10,11 @@ describe '/app/login', type: :request do
context 'with DEFAULT_LOCALE' do
it 'renders the dashboard' do
ENV['DEFAULT_LOCALE'] = 'pt_BR'
get '/app/login'
expect(response).to have_http_status(:success)
expect(response.body).to include "selectedLocale: 'pt_BR'"
ENV['DEFAULT_LOCALE'] = 'en'
with_modified_env DEFAULT_LOCALE: 'pt_BR' do
get '/app/login'
expect(response).to have_http_status(:success)
expect(response.body).to include "selectedLocale: 'pt_BR'"
end
end
end
@ -23,11 +23,11 @@ describe '/app/login', type: :request do
# ref : https://stackoverflow.com/a/63584877/939299
context 'with CW_API_ONLY_SERVER true' do
it 'returns 404' do
ENV['CW_API_ONLY_SERVER'] = 'true'
Rails.application.reload_routes!
get '/app/login'
expect(response).to have_http_status(:not_found)
ENV['CW_API_ONLY_SERVER'] = nil
with_modified_env CW_API_ONLY_SERVER: 'true' do
Rails.application.reload_routes!
get '/app/login'
expect(response).to have_http_status(:not_found)
end
Rails.application.reload_routes!
end
end