Commit 75a8bd20 by Brian Morearty Committed by Jon Yurek

Default fog_public option to true *again* (as stated in documentation).

This was previously fixed in pull request #539 but no spec was added at that time, and it has since been broken.

I fixed it and added a spec.
parent 9bfcebc8
...@@ -70,14 +70,14 @@ module Paperclip ...@@ -70,14 +70,14 @@ module Paperclip
end end
def fog_public(style = default_style) def fog_public(style = default_style)
if defined?(@options[:fog_public]) if @options.has_key?(:fog_public)
if defined?(@options[:fog_public][style]) if @options[:fog_public].respond_to?(:has_key?) && @options[:fog_public].has_key?(style)
return @options[:fog_public][style] @options[:fog_public][style]
else else
return @options[:fog_public] @options[:fog_public]
end end
else else
return true true
end end
end end
......
...@@ -252,7 +252,7 @@ class FogTest < Test::Unit::TestCase ...@@ -252,7 +252,7 @@ class FogTest < Test::Unit::TestCase
@dummy.save @dummy.save
end end
should 'set the @fog_public for a perticular style to false' do should 'set the @fog_public for a particular style to false' do
assert_equal false, @dummy.avatar.instance_variable_get('@options')[:fog_public] assert_equal false, @dummy.avatar.instance_variable_get('@options')[:fog_public]
assert_equal false, @dummy.avatar.fog_public(:thumb) assert_equal false, @dummy.avatar.fog_public(:thumb)
end end
...@@ -267,12 +267,25 @@ class FogTest < Test::Unit::TestCase ...@@ -267,12 +267,25 @@ class FogTest < Test::Unit::TestCase
@dummy.save @dummy.save
end end
should 'set the fog_public for a perticular style to correct value' do should 'set the fog_public for a particular style to correct value' do
assert_equal false, @dummy.avatar.fog_public(:medium) assert_equal false, @dummy.avatar.fog_public(:medium)
assert_equal true, @dummy.avatar.fog_public(:thumb) assert_equal true, @dummy.avatar.fog_public(:thumb)
end end
end end
context "with fog_public not set" do
setup do
rebuild_model(@options)
@dummy = Dummy.new
@dummy.avatar = StringIO.new('.')
@dummy.save
end
should "default fog_public to true" do
assert_equal true, @dummy.avatar.fog_public
end
end
context "with a valid bucket name for a subdomain" do context "with a valid bucket name for a subdomain" do
should "provide an url in subdomain style" do should "provide an url in subdomain style" do
assert_match @dummy.avatar.url, /^https:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png/ assert_match @dummy.avatar.url, /^https:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png/
......
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