Commit dcdcb83b by Prem Sichanugrist

Honor umask. Thank you @sbfaulkner

Closes #214
parent 41bc6b4a
...@@ -44,7 +44,7 @@ module Paperclip ...@@ -44,7 +44,7 @@ module Paperclip
FileUtils.cp(file.path, path(style_name)) FileUtils.cp(file.path, path(style_name))
FileUtils.rm(file.path) FileUtils.rm(file.path)
end end
FileUtils.chmod(0644, path(style_name)) FileUtils.chmod(0666&~File.umask, path(style_name))
end end
@queued_for_write = {} @queued_for_write = {}
end end
......
...@@ -383,6 +383,24 @@ class IntegrationTest < Test::Unit::TestCase ...@@ -383,6 +383,24 @@ class IntegrationTest < Test::Unit::TestCase
assert_equal "5k.png", @dummy.avatar_file_name assert_equal "5k.png", @dummy.avatar_file_name
end end
[000,002,022].each do |umask|
context "when the umask is #{umask}" do
setup do
@umask = File.umask umask
end
teardown do
File.umask @umask
end
should "respect the current umask" do
@dummy.avatar = @file
@dummy.save
assert_equal 0666&~umask, 0666&File.stat(@dummy.avatar.path).mode
end
end
end
context "that is assigned its file from another Paperclip attachment" do context "that is assigned its file from another Paperclip attachment" do
setup do setup do
@dummy2 = Dummy.new @dummy2 = Dummy.new
......
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