test/storage_test.rb in thoughtbot-paperclip-2.2.8 vs test/storage_test.rb in thoughtbot-paperclip-2.2.9.1

- old
+ new

@@ -8,33 +8,33 @@ :s3_credentials => {:not => :important} @dummy = Dummy.new @avatar = @dummy.avatar - @current_env = ENV['RAILS_ENV'] + @current_env = RAILS_ENV end teardown do - ENV['RAILS_ENV'] = @current_env + Object.const_set("RAILS_ENV", @current_env) end 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"}, @avatar.parse_credentials('production' => {:key => '12345'}, :development => {:key => "54321"})) end 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"}, @avatar.parse_credentials('production' => {:key => '12345'}, :development => {:key => "54321"})) end 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")) end end context "" do @@ -92,16 +92,21 @@ :s3_credentials => { :production => { :bucket => "prod_bucket" }, :development => { :bucket => "dev_bucket" } } @dummy = Dummy.new + @old_env = RAILS_ENV 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 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 end end context "An attachment with S3 storage" do