Commit e90de5da by Prem Sichanugrist

Remove whitespaces

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