Permalink
Browse files

Make File#atomic_write tests pass with umask

  Assertions on file permissions only pass with some combinations of
file create mode and the process file mode creation mask. This mask
should be applied on the file create mode before related assertions.
  • Loading branch information...
1 parent 70ad12a commit 7b6bf02303e91932fd3c5824e88f7a58424a7b60 @tjouan tjouan committed May 29, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 activesupport/test/core_ext/file_test.rb
@@ -30,15 +30,15 @@ def test_atomic_write_preserves_file_permissions
assert File.exist?(file_name)
end
assert File.exist?(file_name)
- assert_equal 0100755, file_mode
+ assert_equal 0100755 & ~File.umask, file_mode
assert_equal contents, File.read(file_name)
File.atomic_write(file_name, Dir.pwd) do |file|
file.write(contents)
assert File.exist?(file_name)
end
assert File.exist?(file_name)
- assert_equal 0100755, file_mode
+ assert_equal 0100755 & ~File.umask, file_mode
assert_equal contents, File.read(file_name)
ensure
File.unlink(file_name) rescue nil
@@ -51,7 +51,7 @@ def test_atomic_write_preserves_default_file_permissions
assert !File.exist?(file_name)
end
assert File.exist?(file_name)
- assert_equal 0100666 ^ File.umask, file_mode
+ assert_equal 0100666 & ~File.umask, file_mode
assert_equal contents, File.read(file_name)
ensure
File.unlink(file_name) rescue nil

0 comments on commit 7b6bf02

Please sign in to comment.