Skip to content
Permalink
Browse files

Remove integration with `RAILS_ENV`

  • Loading branch information
benlangfeld committed Jun 15, 2015
1 parent 82d9600 commit f4d4b024d3000c1fa5608914edc2d2a1e5875207
@@ -13,6 +13,6 @@ matrix:
allow_failures:
- rvm: rbx-2.1.1
- rvm: ruby-head
env: ARUBA_TIMEOUT=120 RAILS_ENV=development AHN_ENV=development
env: ARUBA_TIMEOUT=120 AHN_ENV=development
notifications:
irc: "irc.freenode.org#adhearsion"
@@ -1,5 +1,6 @@
# [develop](https://github.com/adhearsion/adhearsion)
* Change: Removed `Adhearsion.ahn_root=` which was deprecated in favour of `Adhearsion.root=`
* Change: Remove integration with `RAILS_ENV`

# [2.6.1](https://github.com/adhearsion/adhearsion/compare/v2.6.0...v2.6.1) - [2015-06-15](https://rubygems.org/gems/adhearsion/versions/2.6.1)
* Bugfix: Improve Call initialization performance. Use an ActorProxy (subclass) instead of a method_missing definition on every Call.new. This considerably improves Call.new performance; benchmarks show approximately a 30-40% improvement: https://gist.github.com/kares/3576e272250204eb66d1
@@ -52,7 +52,7 @@ def initialize_config
end

def environment
ENV['AHN_ENV'] || ENV['RAILS_ENV'] || :development
ENV['AHN_ENV'] || :development
end

def environments
@@ -116,7 +116,7 @@ def execute_from_app_dir!(path)
raise PathInvalid, path unless File.directory?(path)

raise PathInvalid, path unless ScriptAhnLoader.in_ahn_application?(path)
# load script/ahn which than boots the Rails environment :
# load script/ahn which then boots the application environment
Dir.chdir(path) { ScriptAhnLoader.load_script_ahn(path) }
path
end
@@ -60,7 +60,6 @@ def start
catch_termination_signal
set_ahn_proc_name
initialize_exception_logger
update_rails_env_var
init_plugins

run_plugins
@@ -92,25 +91,6 @@ def debugging_log
end
end

def update_rails_env_var
env = ENV['AHN_ENV']
if env && Adhearsion.config.valid_environment?(env.to_sym)
unless ENV['RAILS_ENV']
logger.info "Copying AHN_ENV (#{env}) to RAILS_ENV"
ENV['RAILS_ENV'] = env
end
else
unless ENV['RAILS_ENV']
env = Adhearsion.config.platform.environment.to_s
ENV['AHN_ENV'] = env
logger.info "Setting RAILS_ENV to \"#{env}\""
ENV['RAILS_ENV'] = env
end
end
logger.warn "AHN_ENV(#{ENV['AHN_ENV']}) does not match RAILS_ENV(#{ENV['RAILS_ENV']})!" unless ENV['RAILS_ENV'] == ENV['AHN_ENV']
env
end

def default_pid_path
File.join Adhearsion.config.root, DEFAULT_PID_FILE_NAME
end
@@ -196,83 +196,3 @@
end
end
end

describe "Updating RAILS_ENV variable" do
include InitializerStubs

before do
::Logging.reset
expect(Adhearsion::Logging).to receive(:start).once.and_return('')
expect(::Logging::Appenders).to receive(:file).and_return(nil)
Adhearsion.config = nil
end

before do
ENV['RAILS_ENV'] = nil
ENV['AHN_ENV'] = nil
end

after :all do
ENV['RAILS_ENV'] = nil
ENV['AHN_ENV'] = nil
end

describe "when neither RAILS_ENV nor AHN_ENV are set" do
[:development, :production, :staging, :test].each do |env|
it "should set the RAILS_ENV to #{env.to_s} when Adhearsion environment is set to #{env.to_s}" do
ahn = nil
stub_behavior_for_initializer_with_no_path_changing_behavior do
Adhearsion.config.platform.environment = env
ahn = Adhearsion::Initializer.start
end
ahn.update_rails_env_var
expect(ENV['RAILS_ENV']).to eq(env.to_s)
end
end
end

context "when RAILS_ENV is set" do
before do
ENV['RAILS_ENV'] = "test"
end

context "if AHN_ENV is set" do
it "should preserve the RAILS_ENV value" do
ENV['AHN_ENV'] = "production"
ahn = nil
stub_behavior_for_initializer_with_no_path_changing_behavior do
ahn = Adhearsion::Initializer.start
end
ahn.update_rails_env_var
expect(ENV['RAILS_ENV']).to eq("test")
end
end

context "if AHN_ENV is unset" do
it "should preserve the RAILS_ENV value" do
ahn = nil
stub_behavior_for_initializer_with_no_path_changing_behavior do
ahn = Adhearsion::Initializer.start
end
ahn.update_rails_env_var
expect(ENV['RAILS_ENV']).to eq("test")
end
end
end

context "when RAILS_ENV is unset and AHN_ENV is set" do
before do
ENV['AHN_ENV'] = "production"
end

it "should define the RAILS_ENV value with the AHN_ENV value" do
ahn = nil
stub_behavior_for_initializer_with_no_path_changing_behavior do
ahn = Adhearsion::Initializer.start
end
ahn.update_rails_env_var
expect(ENV['RAILS_ENV']).to eq("production")
end
end

end
@@ -2,7 +2,7 @@

module InitializerStubs
UNWANTED_BEHAVIOR = {
Adhearsion::Initializer => [:debugging_log, :initialize_log_paths, :update_rails_env_var, :require, :load, :init_plugins, :run_plugins]
Adhearsion::Initializer => [:debugging_log, :initialize_log_paths, :require, :load, :init_plugins, :run_plugins]
} unless defined? UNWANTED_BEHAVIOR

def stub_behavior_for_initializer_with_no_path_changing_behavior

0 comments on commit f4d4b02

Please sign in to comment.
You can’t perform that action at this time.