Permalink
Browse files

Honor umask. Thank you @sbfaulkner

Closes #214
  • Loading branch information...
1 parent 41bc6b4 commit dcdcb83baaca22964bdc8e76747cafa0c1bb87b3 @sikachu sikachu committed Jun 29, 2011
Showing with 19 additions and 1 deletion.
  1. +1 −1 lib/paperclip/storage/filesystem.rb
  2. +18 −0 test/integration_test.rb
@@ -44,7 +44,7 @@ def flush_writes #:nodoc:
FileUtils.cp(file.path, path(style_name))
FileUtils.rm(file.path)
end
- FileUtils.chmod(0644, path(style_name))
+ FileUtils.chmod(0666&~File.umask, path(style_name))
end
@queued_for_write = {}
end
@@ -383,6 +383,24 @@ class IntegrationTest < Test::Unit::TestCase
assert_equal "5k.png", @dummy.avatar_file_name
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
setup do
@dummy2 = Dummy.new

0 comments on commit dcdcb83

Please sign in to comment.