From 9bbb272b347fd9e5174ea49c39d88c7059a64b4f Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 24 Oct 2014 18:29:11 -0500 Subject: [PATCH] Automatically add ugoira tag to ugoira posts. Note that this only adds the ugoira tag to .zip posts. It does not remove the ugoira tag for posts converted from ugoira, but that aren't true ugoira. --- app/models/post.rb | 8 ++++++-- test/unit/post_test.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index dbe8e896f..33ed75d44 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -562,14 +562,18 @@ class Post < ActiveRecord::Base tags << "huge_filesize" end - if file_ext == "swf" + if is_flash? tags << "flash" end - if file_ext == "webm" + if is_video? tags << "webm" end + if is_ugoira? + tags << "ugoira" + end + return tags end diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index a15a73e2b..85f9cf3a7 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -641,6 +641,42 @@ class PostTest < ActiveSupport::TestCase end end + context "with a .zip file extension" do + setup do + @post.file_ext = "zip" + @post.tag_string = "" + @post.save + end + + should "have the appropriate file type tag added automatically" do + assert_match(/ugoira/, @post.tag_string) + end + end + + context "with a .webm file extension" do + setup do + @post.file_ext = "webm" + @post.tag_string = "" + @post.save + end + + should "have the appropriate file type tag added automatically" do + assert_match(/webm/, @post.tag_string) + end + end + + context "with a .swf file extension" do + setup do + @post.file_ext = "swf" + @post.tag_string = "" + @post.save + end + + should "have the appropriate file type tag added automatically" do + assert_match(/flash/, @post.tag_string) + end + end + context "that has been updated" do should "create a new version if it's the first version" do assert_difference("PostVersion.count", 1) do