Permalink
Browse files

Force loading of shards configuration when asking for environments

Closes GH-88
Closes GH-94
  • Loading branch information...
1 parent df49652 commit 9f8862e614e139b34ab47b431157568e971400ca @sobrinho sobrinho committed Sep 22, 2012
Showing with 24 additions and 5 deletions.
  1. +1 −5 lib/octopus.rb
  2. +22 −0 spec/octopus/octopus_spec.rb
  3. +1 −0 spec/octopus/proxy_spec.rb
View
@@ -20,10 +20,6 @@ def self.config
if File.exists?(file_name)
config ||= HashWithIndifferentAccess.new(YAML.load(ERB.new(File.open(file_name).read()).result))[Octopus.env()]
-
- if config && config['environments']
- self.environments = config['environments']
- end
else
config ||= HashWithIndifferentAccess.new
end
@@ -65,7 +61,7 @@ def self.environments=(environments)
end
def self.environments
- @environments || ['production']
+ @environments ||= config['environments'] || ['production']
end
def self.rails3?
@@ -65,4 +65,26 @@
end
end
end
+
+ describe "#enabled?" do
+ before do
+ Rails = mock()
+ end
+
+ after do
+ Object.send(:remove_const, :Rails)
+ end
+
+ it "should be if octopus is configured and should hook into current environment" do
+ Rails.stub!(:env).and_return('production')
+
+ Octopus.should be_enabled
+ end
+
+ it "should not be if octopus should not hook into current environment" do
+ Rails.stub!(:env).and_return('staging')
+
+ Octopus.should_not be_enabled
+ end
+ end
end
@@ -127,6 +127,7 @@
it "should initialize correctly octopus common variables for the environments" do
Rails.stub!(:env).and_return('staging')
Octopus.instance_variable_set(:@rails_env, nil)
+ Octopus.instance_variable_set(:@environments, nil)
Octopus.config()
proxy.instance_variable_get(:@replicated).should be_true

0 comments on commit 9f8862e

Please sign in to comment.