aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorPhilippe Huibonhoa <phuibonhoa@gmail.com>2011-09-21 21:00:46 -0700
committerPhilippe Huibonhoa <phuibonhoa@gmail.com>2011-09-21 21:00:46 -0700
commit8d63678d1406c5518d437709af0fde717c0248d7 (patch)
tree823e14613a73667d99574824a3cd573fd6041e38 /activesupport/test
parent51bef9d8fb0b4da7a104425ab8545e9331387743 (diff)
downloadrails-8d63678d1406c5518d437709af0fde717c0248d7.tar.gz
rails-8d63678d1406c5518d437709af0fde717c0248d7.tar.bz2
rails-8d63678d1406c5518d437709af0fde717c0248d7.zip
Fixed issue in file store where it could create a filename that was too long for the file system. (https://github.com/rails/rails/issues/3072)
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/caching_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb
index 6bb13ec9b8..6b113594cc 100644
--- a/activesupport/test/caching_test.rb
+++ b/activesupport/test/caching_test.rb
@@ -557,6 +557,15 @@ class FileStoreTest < ActiveSupport::TestCase
key = @cache_with_pathname.send(:key_file_path, "views/index?id=1")
assert_equal "views/index?id=1", @cache_with_pathname.send(:file_path_key, key)
end
+
+ # Because file systems have a maximum filename size, filenames > max size should be split in to directories
+ # If filename is 'AAAAB', where max size is 4, the returned path should be AAAA/B
+ def test_key_transformation_max_filename_size
+ key = "#{'A' * ActiveSupport::Cache::FileStore::FILENAME_MAX_SIZE}B"
+ path = @cache.send(:key_file_path, key)
+ assert path.split('/').all? { |dir_name| dir_name.size <= ActiveSupport::Cache::FileStore::FILENAME_MAX_SIZE}
+ assert_equal 'B', File.basename(path)
+ end
end
class MemoryStoreTest < ActiveSupport::TestCase