Commit fceb929f authored by Roy Zwambag's avatar Roy Zwambag

Move override_rails_constants.rb to another location

We move override_rails_constants.rb to another location so that it's
closer to its related code in metrics_server.
We also remove the usage in setup-test-env as they differ in usage, and
reusing the code does not make a lot of sense.
parent a795c13a
......@@ -3,12 +3,12 @@
require 'active_support/environment_inquirer'
module Rails # rubocop:disable Gitlab/NamespacedClass
module Rails
extend self
def env
@env ||= ActiveSupport::EnvironmentInquirer.new(
ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "test"
ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "development"
)
end
......
......@@ -7,7 +7,7 @@
# to all necessary constants. For example, we need Rails.root to
# determine the location of bin/metrics-server.
# Here we make the necessary constants available conditionally.
require_relative '../scripts/override_rails_constants' unless Object.const_defined?('Rails')
require_relative 'override_rails_constants' unless Object.const_defined?('Rails')
require_relative '../config/settings'
......
......@@ -13,7 +13,17 @@ require 'active_support/string_inquirer'
ENV['SKIP_RAILS_ENV_IN_RAKE'] = 'true'
require_relative 'override_rails_constants'
module Rails
extend self
def root
Pathname.new(File.expand_path('..', __dir__))
end
def env
@_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "test")
end
end
ActiveSupport::Dependencies.autoload_paths << 'lib'
......
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