Auto-add automatic tags whenever post is updated
Instead of being limited to when it's first uploaded.
This commit is contained in:
@@ -7,8 +7,8 @@ FactoryGirl.define do
|
||||
tag_count 2
|
||||
tag_count_general 2
|
||||
file_ext "jpg"
|
||||
image_width 100
|
||||
image_height 200
|
||||
image_width 1500
|
||||
image_height 1000
|
||||
file_size 2000
|
||||
rating "q"
|
||||
end
|
||||
|
||||
@@ -608,6 +608,33 @@ class PostTest < ActiveSupport::TestCase
|
||||
assert_equal(%w(tag1 tag2), post.tag_array_was)
|
||||
end
|
||||
|
||||
context "with large dimensions" do
|
||||
setup do
|
||||
@post.image_width = 10_000
|
||||
@post.image_height = 10
|
||||
@post.tag_string = ""
|
||||
@post.save
|
||||
end
|
||||
|
||||
should "have the appropriate dimension tags added automatically" do
|
||||
assert_match(/incredibly_absurdres/, @post.tag_string)
|
||||
assert_match(/absurdres/, @post.tag_string)
|
||||
assert_match(/highres/, @post.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a large file size" do
|
||||
setup do
|
||||
@post.file_size = 11.megabytes
|
||||
@post.tag_string = ""
|
||||
@post.save
|
||||
end
|
||||
|
||||
should "have the appropriate file size tags added automatically" do
|
||||
assert_match(/huge_filesize/, @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
|
||||
|
||||
@@ -36,31 +36,6 @@ class UploadTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "that has incredibly absurd res dimensions" do
|
||||
setup do
|
||||
@upload = FactoryGirl.build(:jpg_upload, :tag_string => "")
|
||||
@upload.image_width = 10_000
|
||||
@upload.image_height = 10
|
||||
@upload.add_dimension_tags!
|
||||
end
|
||||
|
||||
should "have the incredibly_absurdres tag" do
|
||||
assert_match(/incredibly_absurdres/, @upload.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
context "that has a large flie size" do
|
||||
setup do
|
||||
@upload = FactoryGirl.build(:jpg_upload, :tag_string => "")
|
||||
@upload.file_size = 11.megabytes
|
||||
@upload.add_file_size_tags!(@upload.file_path)
|
||||
end
|
||||
|
||||
should "have the huge_filesize tag" do
|
||||
assert_match(/huge_filesize/, @upload.tag_string)
|
||||
end
|
||||
end
|
||||
|
||||
context "image size calculator" do
|
||||
should "discover the dimensions for a compressed SWF" do
|
||||
@upload = FactoryGirl.create(:upload, :file_path => "#{Rails.root}/test/files/compressed.swf")
|
||||
|
||||
Reference in New Issue
Block a user