Merge pull request #2282 from evazion/feat-autotag-ugoira
Automatically add ugoira tag to ugoira posts.
This commit is contained in:
@@ -562,14 +562,18 @@ class Post < ActiveRecord::Base
|
|||||||
tags << "huge_filesize"
|
tags << "huge_filesize"
|
||||||
end
|
end
|
||||||
|
|
||||||
if file_ext == "swf"
|
if is_flash?
|
||||||
tags << "flash"
|
tags << "flash"
|
||||||
end
|
end
|
||||||
|
|
||||||
if file_ext == "webm"
|
if is_video?
|
||||||
tags << "webm"
|
tags << "webm"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if is_ugoira?
|
||||||
|
tags << "ugoira"
|
||||||
|
end
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -641,6 +641,42 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
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
|
context "that has been updated" do
|
||||||
should "create a new version if it's the first version" do
|
should "create a new version if it's the first version" do
|
||||||
assert_difference("PostVersion.count", 1) do
|
assert_difference("PostVersion.count", 1) do
|
||||||
|
|||||||
Reference in New Issue
Block a user