From be0c2cfcfaf1384c116e049500b7e1bdde3fda2b Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 28 Mar 2018 18:37:40 -0500 Subject: [PATCH] posts: fix incorrect large_file_url for animated_gifs. For animated_gif posts, large_file_url was returning "/data/sample-$md5.jpg" instead of "/data/$md5.gif". --- app/logical/storage_manager.rb | 2 +- test/unit/post_test.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/logical/storage_manager.rb b/app/logical/storage_manager.rb index 1ce833f88..570a49373 100644 --- a/app/logical/storage_manager.rb +++ b/app/logical/storage_manager.rb @@ -56,7 +56,7 @@ class StorageManager elsif type == :large && post.has_large? "#{base_url}/sample/#{subdir}#{seo_tags(post)}#{file}" else - "#{base_url}/#{subdir}#{seo_tags(post)}#{file}" + "#{base_url}/#{subdir}#{seo_tags(post)}#{post.md5}.#{post.file_ext}" end end diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index a09ba0134..ddb133250 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -2653,6 +2653,16 @@ class PostTest < ActiveSupport::TestCase end end + context "URLs:" do + should "generate the correct urls for animated gifs" do + @post = FactoryGirl.build(:post, md5: "deadbeef", file_ext: "gif", tag_string: "animated_gif") + + assert_equal("http://localhost/data/preview/deadbeef.jpg", @post.preview_file_url) + assert_equal("http://localhost/data/deadbeef.gif", @post.large_file_url) + assert_equal("http://localhost/data/deadbeef.gif", @post.file_url) + end + end + context "Mass assignment: " do should_not allow_mass_assignment_of(:last_noted_at).as(:member) end