Commit d591a648 by Mike Burns

Fix the formatting.

parent 5ec9a737
...@@ -119,16 +119,16 @@ module Paperclip ...@@ -119,16 +119,16 @@ module Paperclip
directory.files.new(:key => path(style)).public_url directory.files.new(:key => path(style)).public_url
end end
end end
def parse_credentials creds def parse_credentials(creds)
creds = find_credentials(creds).stringify_keys creds = find_credentials(creds).stringify_keys
env = Object.const_defined?(:Rails) ? Rails.env : nil env = Object.const_defined?(:Rails) ? Rails.env : nil
(creds[env] || creds).symbolize_keys (creds[env] || creds).symbolize_keys
end end
private private
def find_credentials creds def find_credentials(creds)
case creds case creds
when File when File
YAML::load(ERB.new(File.read(creds.path)).result) YAML::load(ERB.new(File.read(creds.path)).result)
...@@ -140,7 +140,7 @@ module Paperclip ...@@ -140,7 +140,7 @@ module Paperclip
raise ArgumentError, "Credentials are not a path, file, or hash." raise ArgumentError, "Credentials are not a path, file, or hash."
end end
end end
def connection def connection
@connection ||= ::Fog::Storage.new(@fog_credentials) @connection ||= ::Fog::Storage.new(@fog_credentials)
end end
......
...@@ -5,7 +5,7 @@ Fog.mock! ...@@ -5,7 +5,7 @@ Fog.mock!
class FogTest < Test::Unit::TestCase class FogTest < Test::Unit::TestCase
context "" do context "" do
context "with credentials provided in a path string" do context "with credentials provided in a path string" do
setup do setup do
rebuild_model :styles => { :medium => "300x300>", :thumb => "100x100>" }, rebuild_model :styles => { :medium => "300x300>", :thumb => "100x100>" },
...@@ -21,7 +21,7 @@ class FogTest < Test::Unit::TestCase ...@@ -21,7 +21,7 @@ class FogTest < Test::Unit::TestCase
assert_equal @dummy.avatar.instance_variable_get("@fog_credentials")[:provider], 'AWS' assert_equal @dummy.avatar.instance_variable_get("@fog_credentials")[:provider], 'AWS'
end end
end end
context "with credentials provided in a File object" do context "with credentials provided in a File object" do
setup do setup do
rebuild_model :styles => { :medium => "300x300>", :thumb => "100x100>" }, rebuild_model :styles => { :medium => "300x300>", :thumb => "100x100>" },
...@@ -37,8 +37,7 @@ class FogTest < Test::Unit::TestCase ...@@ -37,8 +37,7 @@ class FogTest < Test::Unit::TestCase
assert_equal @dummy.avatar.instance_variable_get("@fog_credentials")[:provider], 'AWS' assert_equal @dummy.avatar.instance_variable_get("@fog_credentials")[:provider], 'AWS'
end end
end end
context "with default values for path and url" do context "with default values for path and url" do
setup do setup do
rebuild_model :styles => { :medium => "300x300>", :thumb => "100x100>" }, rebuild_model :styles => { :medium => "300x300>", :thumb => "100x100>" },
...@@ -59,7 +58,7 @@ class FogTest < Test::Unit::TestCase ...@@ -59,7 +58,7 @@ class FogTest < Test::Unit::TestCase
@dummy.avatar.path @dummy.avatar.path
end end
end end
setup do setup do
@fog_directory = 'papercliptests' @fog_directory = 'papercliptests'
...@@ -165,7 +164,7 @@ class FogTest < Test::Unit::TestCase ...@@ -165,7 +164,7 @@ class FogTest < Test::Unit::TestCase
assert @dummy.avatar.url =~ /^http:\/\/img[0123]\.example\.com\/avatars\/stringio\.txt\?\d*$/ assert @dummy.avatar.url =~ /^http:\/\/img[0123]\.example\.com\/avatars\/stringio\.txt\?\d*$/
end end
end end
context "with fog_public set to false" do context "with fog_public set to false" do
setup do setup do
rebuild_model(@options.merge(:fog_public => false)) rebuild_model(@options.merge(:fog_public => false))
...@@ -173,7 +172,7 @@ class FogTest < Test::Unit::TestCase ...@@ -173,7 +172,7 @@ class FogTest < Test::Unit::TestCase
@dummy.avatar = StringIO.new('.') @dummy.avatar = StringIO.new('.')
@dummy.save @dummy.save
end end
should 'set the @fog_public instance variable to false' do should 'set the @fog_public instance variable to false' do
assert_equal false, @dummy.avatar.instance_variable_get('@fog_public') assert_equal false, @dummy.avatar.instance_variable_get('@fog_public')
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