Commit e90de5da by Prem Sichanugrist

Remove whitespaces

parent d46a1afe
...@@ -119,14 +119,14 @@ module Paperclip ...@@ -119,14 +119,14 @@ module Paperclip
end end
end end
end end
def expiring_url(time = 3600, style = default_style) def expiring_url(time = 3600, style = default_style)
expiring_url = directory.files.get_http_url(path(style), time) expiring_url = directory.files.get_http_url(path(style), time)
if @options[:fog_host] if @options[:fog_host]
expiring_url.gsub!(/#{host_name_for_directory}/, dynamic_fog_host_for_style(style)) expiring_url.gsub!(/#{host_name_for_directory}/, dynamic_fog_host_for_style(style))
end end
return expiring_url return expiring_url
end end
...@@ -148,7 +148,7 @@ module Paperclip ...@@ -148,7 +148,7 @@ module Paperclip
end end
private private
def dynamic_fog_host_for_style(style) def dynamic_fog_host_for_style(style)
if @options[:fog_host].respond_to?(:call) if @options[:fog_host].respond_to?(:call)
@options[:fog_host].call(self) @options[:fog_host].call(self)
...@@ -156,12 +156,12 @@ module Paperclip ...@@ -156,12 +156,12 @@ module Paperclip
(@options[:fog_host] =~ /%d/) ? @options[:fog_host] % (path(style).hash % 4) : @options[:fog_host] (@options[:fog_host] =~ /%d/) ? @options[:fog_host] % (path(style).hash % 4) : @options[:fog_host]
end end
end end
def host_name_for_directory def host_name_for_directory
if @options[:fog_directory].to_s =~ Fog::AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX if @options[:fog_directory].to_s =~ Fog::AWS_BUCKET_SUBDOMAIN_RESTRICTON_REGEX
# This: # This:
"#{@options[:fog_directory]}." "#{@options[:fog_directory]}."
# Should be modified to this: # Should be modified to this:
# "#{@options[:fog_directory]}.s3.amazonaws.com" # "#{@options[:fog_directory]}.s3.amazonaws.com"
# When fog with https://github.com/fog/fog/pull/857 gets released # When fog with https://github.com/fog/fog/pull/857 gets released
......
...@@ -208,7 +208,7 @@ class FogTest < Test::Unit::TestCase ...@@ -208,7 +208,7 @@ class FogTest < Test::Unit::TestCase
# For now, use this passing one: # For now, use this passing one:
assert_match /^https:\/\/papercliptests.\/avatars\/5k.png\?\d*$/, @dummy.avatar.url assert_match /^https:\/\/papercliptests.\/avatars\/5k.png\?\d*$/, @dummy.avatar.url
end end
should "provide an url that expires in subdomain style" do should "provide an url that expires in subdomain style" do
# The following line is the correct one when this pull request in Fog is released: # The following line is the correct one when this pull request in Fog is released:
# https://github.com/fog/fog/pull/857 # https://github.com/fog/fog/pull/857
...@@ -236,7 +236,7 @@ class FogTest < Test::Unit::TestCase ...@@ -236,7 +236,7 @@ class FogTest < Test::Unit::TestCase
should "provide an url in folder style" do should "provide an url in folder style" do
assert_match /^https:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?\d*$/, @dummy.avatar.url assert_match /^https:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?\d*$/, @dummy.avatar.url
end end
should "provide a url that expires in folder style" do should "provide a url that expires in folder style" do
assert_match /^http:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?AWSAccessKeyId=.+$/, @dummy.avatar.expiring_url assert_match /^http:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png\?AWSAccessKeyId=.+$/, @dummy.avatar.expiring_url
end end
...@@ -271,9 +271,9 @@ class FogTest < Test::Unit::TestCase ...@@ -271,9 +271,9 @@ class FogTest < Test::Unit::TestCase
should "provide a public url" do should "provide a public url" do
assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.url assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.url
end end
end end
context "with a custom fog_host" do context "with a custom fog_host" do
setup do setup do
rebuild_model(@options.merge(:fog_host => "http://dynamicfoghost.com")) rebuild_model(@options.merge(:fog_host => "http://dynamicfoghost.com"))
...@@ -281,15 +281,15 @@ class FogTest < Test::Unit::TestCase ...@@ -281,15 +281,15 @@ class FogTest < Test::Unit::TestCase
@dummy.avatar = @file @dummy.avatar = @file
@dummy.save @dummy.save
end end
should "provide a public url" do should "provide a public url" do
assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.url assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.url
end end
should "provide an expiring url" do should "provide an expiring url" do
assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.expiring_url assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.expiring_url
end end
context "with an invalid bucket name for a subdomain" do context "with an invalid bucket name for a subdomain" do
setup do setup do
rebuild_model(@options.merge({:fog_directory => "this_is_invalid", :fog_host => "http://dynamicfoghost.com"})) rebuild_model(@options.merge({:fog_directory => "this_is_invalid", :fog_host => "http://dynamicfoghost.com"}))
...@@ -297,12 +297,12 @@ class FogTest < Test::Unit::TestCase ...@@ -297,12 +297,12 @@ class FogTest < Test::Unit::TestCase
@dummy.avatar = @file @dummy.avatar = @file
@dummy.save @dummy.save
end end
should "provide an expiring url" do should "provide an expiring url" do
assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.expiring_url assert_match /http:\/\/dynamicfoghost\.com/, @dummy.avatar.expiring_url
end end
end end
end end
context "with a proc for the fog_credentials evaluating a model method" do context "with a proc for the fog_credentials evaluating a model method" do
......
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