Commit 93073d5f by Jon Yurek

Changed ENV['RAILS_ENV'] to plain RAILS_ENV

parent f47a4b5a
...@@ -173,7 +173,7 @@ module Paperclip ...@@ -173,7 +173,7 @@ module Paperclip
def parse_credentials creds def parse_credentials creds
creds = find_credentials(creds).stringify_keys creds = find_credentials(creds).stringify_keys
(creds[ENV['RAILS_ENV']] || creds).symbolize_keys (creds[RAILS_ENV] || creds).symbolize_keys
end end
def exists?(style = default_style) def exists?(style = default_style)
......
...@@ -26,8 +26,6 @@ require File.join(ROOT, 'lib', 'paperclip.rb') ...@@ -26,8 +26,6 @@ require File.join(ROOT, 'lib', 'paperclip.rb')
require 'shoulda_macros/paperclip' require 'shoulda_macros/paperclip'
ENV['RAILS_ENV'] ||= 'test'
FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures") FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')) config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log") ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
......
...@@ -10,29 +10,29 @@ class StorageTest < Test::Unit::TestCase ...@@ -10,29 +10,29 @@ class StorageTest < Test::Unit::TestCase
@dummy = Dummy.new @dummy = Dummy.new
@avatar = @dummy.avatar @avatar = @dummy.avatar
@current_env = ENV['RAILS_ENV'] @current_env = RAILS_ENV
end end
teardown do teardown do
ENV['RAILS_ENV'] = @current_env Object.const_set("RAILS_ENV", @current_env)
end end
should "get the correct credentials when RAILS_ENV is production" do should "get the correct credentials when RAILS_ENV is production" do
ENV['RAILS_ENV'] = 'production' Object.const_set('RAILS_ENV', "production")
assert_equal({:key => "12345"}, assert_equal({:key => "12345"},
@avatar.parse_credentials('production' => {:key => '12345'}, @avatar.parse_credentials('production' => {:key => '12345'},
:development => {:key => "54321"})) :development => {:key => "54321"}))
end end
should "get the correct credentials when RAILS_ENV is development" do should "get the correct credentials when RAILS_ENV is development" do
ENV['RAILS_ENV'] = 'development' Object.const_set('RAILS_ENV', "development")
assert_equal({:key => "54321"}, assert_equal({:key => "54321"},
@avatar.parse_credentials('production' => {:key => '12345'}, @avatar.parse_credentials('production' => {:key => '12345'},
:development => {:key => "54321"})) :development => {:key => "54321"}))
end end
should "return the argument if the key does not exist" do should "return the argument if the key does not exist" do
ENV['RAILS_ENV'] = "not really an env" Object.const_set('RAILS_ENV', "not really an env")
assert_equal({:test => "12345"}, @avatar.parse_credentials(:test => "12345")) assert_equal({:test => "12345"}, @avatar.parse_credentials(:test => "12345"))
end end
end end
...@@ -94,13 +94,18 @@ class StorageTest < Test::Unit::TestCase ...@@ -94,13 +94,18 @@ class StorageTest < Test::Unit::TestCase
:development => { :bucket => "dev_bucket" } :development => { :bucket => "dev_bucket" }
} }
@dummy = Dummy.new @dummy = Dummy.new
@old_env = RAILS_ENV
end end
should "get the right bucket in production", :before => lambda{ ENV.expects(:[]).returns('production') } do teardown{ Object.const_set("RAILS_ENV", @old_env) }
should "get the right bucket in production" do
Object.const_set("RAILS_ENV", "production")
assert_equal "prod_bucket", @dummy.avatar.bucket_name assert_equal "prod_bucket", @dummy.avatar.bucket_name
end end
should "get the right bucket in development", :before => lambda{ ENV.expects(:[]).returns('development') } do should "get the right bucket in development" do
Object.const_set("RAILS_ENV", "development")
assert_equal "dev_bucket", @dummy.avatar.bucket_name assert_equal "dev_bucket", @dummy.avatar.bucket_name
end end
end end
......
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