diff options
author | George Claghorn <george.claghorn@gmail.com> | 2017-08-20 16:30:15 -0400 |
---|---|---|
committer | George Claghorn <george.claghorn@gmail.com> | 2017-08-20 16:30:15 -0400 |
commit | 8bd14971b908b7d3c7b41a715d2904df88ee7b3c (patch) | |
tree | ba0ef905ea034c3074073ca371d8a0d9a9650bab /activestorage/test | |
parent | 81ca1556b6181fb62a3d6b9f0c14fb38f6fd1b57 (diff) | |
download | rails-8bd14971b908b7d3c7b41a715d2904df88ee7b3c.tar.gz rails-8bd14971b908b7d3c7b41a715d2904df88ee7b3c.tar.bz2 rails-8bd14971b908b7d3c7b41a715d2904df88ee7b3c.zip |
Rename ActiveStorage::Filename#extname to extension_with_delimiter
Diffstat (limited to 'activestorage/test')
-rw-r--r-- | activestorage/test/models/filename_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activestorage/test/models/filename_test.rb b/activestorage/test/models/filename_test.rb index f1e4a467ba..88405e41c0 100644 --- a/activestorage/test/models/filename_test.rb +++ b/activestorage/test/models/filename_test.rb @@ -3,6 +3,24 @@ require "test_helper" class ActiveStorage::FilenameTest < ActiveSupport::TestCase + test "base" do + assert_equal "racecar", ActiveStorage::Filename.new("racecar.jpg").base + assert_equal "race.car", ActiveStorage::Filename.new("race.car.jpg").base + assert_equal "racecar", ActiveStorage::Filename.new("racecar").base + end + + test "extension with delimiter" do + assert_equal ".jpg", ActiveStorage::Filename.new("racecar.jpg").extension_with_delimiter + assert_equal ".jpg", ActiveStorage::Filename.new("race.car.jpg").extension_with_delimiter + assert_equal "", ActiveStorage::Filename.new("racecar").extension_with_delimiter + end + + test "extension without delimiter" do + assert_equal "jpg", ActiveStorage::Filename.new("racecar.jpg").extension_without_delimiter + assert_equal "jpg", ActiveStorage::Filename.new("race.car.jpg").extension_without_delimiter + assert_equal "", ActiveStorage::Filename.new("racecar").extension_without_delimiter + end + test "sanitize" do "%$|:;/\t\r\n\\".each_char do |character| filename = ActiveStorage::Filename.new("foo#{character}bar.pdf") |