Sha256: 871ac5bea248caa095a619b8fce9ee201ff6c11eeb4098304822a8b9299cf9df

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require './test/helper'

class AwsStorageTest < Test::Unit::TestCase
  def rails_env(env)
    silence_warnings do
      Object.const_set(:Rails, stub('Rails', :env => env))
    end
  end

  context "Parsing S3 credentials" do
    setup do
      @proxy_settings = {:host => "127.0.0.1", :port => 8888, :user => "foo", :password => "bar"}
      Rails.stubs(:const_defined?)
      rebuild_model :storage => :aws,
                    :bucket => "testing",
                    :http_proxy => @proxy_settings,
                    :s3_credentials => {
                      :access_key_id => "ACCESS_KEY_ID",
                      :secret_access_key => "SECRET_ACCESS_KEY"
                    }

      @dummy = Dummy.new
      @avatar = @dummy.avatar
    end
    
    should "get the correct credentials when RAILS_ENV is production" do
      rails_env("production")
      
      assert_equal(
        { :access_key_id => "12345" },
        @avatar.parse_credentials(
          :production => { :access_key_id => '12345' },
          :development => { :access_key_id => '54321' }
        )
      )
    end
    
    should "get the correct credentials when RAILS_ENV is development" do
      rails_env("development")
      
      assert_equal(
        { :access_key_id => "54321" },
        @avatar.parse_credentials(
          :production => { :access_key_id => '12345' },
          :development => { :access_key_id => '54321' }
        )
      )
      
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paperclip-aws-1.3.1 test/aws_storage_test.rb