uncommented tests

This commit is contained in:
albert
2010-02-11 23:19:56 -05:00
parent cdc1f653b6
commit 72d1ece96a

View File

@@ -1,63 +1,63 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class PostTest < ActiveSupport::TestCase class PostTest < ActiveSupport::TestCase
# context "During moderation a post" do context "During moderation a post" do
# setup do setup do
# @post = Factory.create(:post) @post = Factory.create(:post)
# @user = Factory.create(:user) @user = Factory.create(:user)
# end end
#
# should "be unapproved once and only once" do should "be unapproved once and only once" do
# @post.unapprove!("bad", @user, "127.0.0.1") @post.unapprove!("bad", @user, "127.0.0.1")
# assert(@post.is_flagged?, "Post should be flagged.") assert(@post.is_flagged?, "Post should be flagged.")
# assert_not_nil(@post.unapproval, "Post should have an unapproval record.") assert_not_nil(@post.unapproval, "Post should have an unapproval record.")
# assert_equal("bad", @post.unapproval.reason) assert_equal("bad", @post.unapproval.reason)
#
# assert_raise(Unapproval::Error) {@post.unapprove!("bad", @user, "127.0.0.1")} assert_raise(Unapproval::Error) {@post.unapprove!("bad", @user, "127.0.0.1")}
# end end
#
# should "not unapprove if no reason is given" do should "not unapprove if no reason is given" do
# assert_raise(Unapproval::Error) {@post.unapprove!("", @user, "127.0.0.1")} assert_raise(Unapproval::Error) {@post.unapprove!("", @user, "127.0.0.1")}
# end end
#
# should "be deleted" do should "be deleted" do
# @post.delete! @post.delete!
# assert(@post.is_deleted?, "Post should be deleted.") assert(@post.is_deleted?, "Post should be deleted.")
# end end
#
# should "be approved" do should "be approved" do
# @post.approve! @post.approve!
# assert(!@post.is_pending?, "Post should not be pending.") assert(!@post.is_pending?, "Post should not be pending.")
#
# @deleted_post = Factory.create(:post, :is_deleted => true) @deleted_post = Factory.create(:post, :is_deleted => true)
# @deleted_post.approve! @deleted_post.approve!
# assert(!@post.is_deleted?, "Post should not be deleted.") assert(!@post.is_deleted?, "Post should not be deleted.")
# end end
# end end
#
# context "A post version" do context "A post version" do
# should "be created on any save" do should "be created on any save" do
# @user = Factory.create(:user) @user = Factory.create(:user)
# @post = Factory.create(:post) @post = Factory.create(:post)
# assert_equal(1, @post.versions.size) assert_equal(1, @post.versions.size)
#
# @post.update_attributes(:rating => "e", :updater_id => @user.id, :updater_ip_addr => "125.0.0.0") @post.update_attributes(:rating => "e", :updater_id => @user.id, :updater_ip_addr => "125.0.0.0")
# assert_equal(2, @post.versions.size) assert_equal(2, @post.versions.size)
# assert_equal(@user.id, @post.versions.last.updater_id) assert_equal(@user.id, @post.versions.last.updater_id)
# assert_equal("125.0.0.0", @post.versions.last.updater_ip_addr) assert_equal("125.0.0.0", @post.versions.last.updater_ip_addr)
# end end
# end end
#
# context "A post's tags" do context "A post's tags" do
# setup do setup do
# @post = Factory.create(:post) @post = Factory.create(:post)
# end end
#
# should "have an array representation" do should "have an array representation" do
# @post.set_tag_string("aaa bbb") @post.set_tag_string("aaa bbb")
# assert_equal(%w(aaa bbb), @post.tag_array) assert_equal(%w(aaa bbb), @post.tag_array)
# assert_equal(%w(tag1 tag2), @post.tag_array_was) assert_equal(%w(tag1 tag2), @post.tag_array_was)
# end end
should "reset the tag array cache when updated" do should "reset the tag array cache when updated" do
post = Factory.create(:post, :tag_string => "aaa bbb ccc") post = Factory.create(:post, :tag_string => "aaa bbb ccc")
@@ -88,112 +88,112 @@ class PostTest < ActiveSupport::TestCase
assert_equal(3, Tag.find_by_name("ccc").post_count) assert_equal(3, Tag.find_by_name("ccc").post_count)
end end
# should "be counted" do should "be counted" do
# @user = Factory.create(:user) @user = Factory.create(:user)
# @artist_tag = Factory.create(:artist_tag) @artist_tag = Factory.create(:artist_tag)
# @copyright_tag = Factory.create(:copyright_tag) @copyright_tag = Factory.create(:copyright_tag)
# @general_tag = Factory.create(:tag) @general_tag = Factory.create(:tag)
# @new_post = Factory.create(:post, :tag_string => "#{@artist_tag.name} #{@copyright_tag.name} #{@general_tag.name}") @new_post = Factory.create(:post, :tag_string => "#{@artist_tag.name} #{@copyright_tag.name} #{@general_tag.name}")
# assert_equal(1, @new_post.tag_count_artist) assert_equal(1, @new_post.tag_count_artist)
# assert_equal(1, @new_post.tag_count_copyright) assert_equal(1, @new_post.tag_count_copyright)
# assert_equal(1, @new_post.tag_count_general) assert_equal(1, @new_post.tag_count_general)
# assert_equal(0, @new_post.tag_count_character) assert_equal(0, @new_post.tag_count_character)
# assert_equal(3, @new_post.tag_count) assert_equal(3, @new_post.tag_count)
#
# @new_post.update_attributes(:tag_string => "babs", :updater_id => @user.id, :updater_ip_addr => "127.0.0.1") @new_post.update_attributes(:tag_string => "babs", :updater_id => @user.id, :updater_ip_addr => "127.0.0.1")
# assert_equal(0, @new_post.tag_count_artist) assert_equal(0, @new_post.tag_count_artist)
# assert_equal(0, @new_post.tag_count_copyright) assert_equal(0, @new_post.tag_count_copyright)
# assert_equal(1, @new_post.tag_count_general) assert_equal(1, @new_post.tag_count_general)
# assert_equal(0, @new_post.tag_count_character) assert_equal(0, @new_post.tag_count_character)
# assert_equal(1, @new_post.tag_count) assert_equal(1, @new_post.tag_count)
# end end
#
# should "be merged with any changes that were made after loading the initial set of tags part 1" do should "be merged with any changes that were made after loading the initial set of tags part 1" do
# @user = Factory.create(:user) @user = Factory.create(:user)
# @post = Factory.create(:post, :tag_string => "aaa bbb ccc") @post = Factory.create(:post, :tag_string => "aaa bbb ccc")
#
# # user a adds <ddd> # user a adds <ddd>
# @post_edited_by_user_a = Post.find(@post.id) @post_edited_by_user_a = Post.find(@post.id)
# @post_edited_by_user_a.update_attributes( @post_edited_by_user_a.update_attributes(
# :updater_id => @user.id, :updater_id => @user.id,
# :updater_ip_addr => "127.0.0.1", :updater_ip_addr => "127.0.0.1",
# :old_tag_string => "aaa bbb ccc", :old_tag_string => "aaa bbb ccc",
# :tag_string => "aaa bbb ccc ddd" :tag_string => "aaa bbb ccc ddd"
# ) )
#
# # user b removes <ccc> adds <eee> # user b removes <ccc> adds <eee>
# @post_edited_by_user_b = Post.find(@post.id) @post_edited_by_user_b = Post.find(@post.id)
# @post_edited_by_user_b.update_attributes( @post_edited_by_user_b.update_attributes(
# :updater_id => @user.id, :updater_id => @user.id,
# :updater_ip_addr => "127.0.0.1", :updater_ip_addr => "127.0.0.1",
# :old_tag_string => "aaa bbb ccc", :old_tag_string => "aaa bbb ccc",
# :tag_string => "aaa bbb eee" :tag_string => "aaa bbb eee"
# ) )
#
# # final should be <aaa>, <bbb>, <ddd>, <eee> # final should be <aaa>, <bbb>, <ddd>, <eee>
# @final_post = Post.find(@post.id) @final_post = Post.find(@post.id)
# assert_equal(%w(aaa bbb ddd eee), Tag.scan_tags(@final_post.tag_string).sort) assert_equal(%w(aaa bbb ddd eee), Tag.scan_tags(@final_post.tag_string).sort)
# end end
#
# should "be merged with any changes that were made after loading the initial set of tags part 2" do should "be merged with any changes that were made after loading the initial set of tags part 2" do
# # This is the same as part 1, only the order of operations is reversed. # This is the same as part 1, only the order of operations is reversed.
# # The results should be the same. # The results should be the same.
#
# @user = Factory.create(:user) @user = Factory.create(:user)
# @post = Factory.create(:post, :tag_string => "aaa bbb ccc") @post = Factory.create(:post, :tag_string => "aaa bbb ccc")
#
# # user a removes <ccc> adds <eee> # user a removes <ccc> adds <eee>
# @post_edited_by_user_a = Post.find(@post.id) @post_edited_by_user_a = Post.find(@post.id)
# @post_edited_by_user_a.update_attributes( @post_edited_by_user_a.update_attributes(
# :updater_id => @user.id, :updater_id => @user.id,
# :updater_ip_addr => "127.0.0.1", :updater_ip_addr => "127.0.0.1",
# :old_tag_string => "aaa bbb ccc", :old_tag_string => "aaa bbb ccc",
# :tag_string => "aaa bbb eee" :tag_string => "aaa bbb eee"
# ) )
#
# # user b adds <ddd> # user b adds <ddd>
# @post_edited_by_user_b = Post.find(@post.id) @post_edited_by_user_b = Post.find(@post.id)
# @post_edited_by_user_b.update_attributes( @post_edited_by_user_b.update_attributes(
# :updater_id => @user.id, :updater_id => @user.id,
# :updater_ip_addr => "127.0.0.1", :updater_ip_addr => "127.0.0.1",
# :old_tag_string => "aaa bbb ccc", :old_tag_string => "aaa bbb ccc",
# :tag_string => "aaa bbb ccc ddd" :tag_string => "aaa bbb ccc ddd"
# ) )
#
# # final should be <aaa>, <bbb>, <ddd>, <eee> # final should be <aaa>, <bbb>, <ddd>, <eee>
# @final_post = Post.find(@post.id) @final_post = Post.find(@post.id)
# assert_equal(%w(aaa bbb ddd eee), Tag.scan_tags(@final_post.tag_string).sort) assert_equal(%w(aaa bbb ddd eee), Tag.scan_tags(@final_post.tag_string).sort)
# end end
# end end
#
# context "Adding a meta-tag" do context "Adding a meta-tag" do
# setup do setup do
# @post = Factory.create(:post) @post = Factory.create(:post)
# end end
#
# should "be ignored" do should "be ignored" do
# @user = Factory.create(:user) @user = Factory.create(:user)
#
# @post.update_attributes( @post.update_attributes(
# :updater_id => @user.id, :updater_id => @user.id,
# :updater_ip_addr => "127.0.0.1", :updater_ip_addr => "127.0.0.1",
# :tag_string => "aaa pool:1234 pool:test rating:s fav:bob" :tag_string => "aaa pool:1234 pool:test rating:s fav:bob"
# ) )
# assert_equal("aaa", @post.tag_string) assert_equal("aaa", @post.tag_string)
# end end
# end end
#
# context "Favoriting a post" do context "Favoriting a post" do
# should "update the favorite string" do should "update the favorite string" do
# @user = Factory.create(:user) @user = Factory.create(:user)
# @post = Factory.create(:post) @post = Factory.create(:post)
# @post.add_favorite(@user) @post.add_favorite(@user)
# assert_equal("fav:#{@user.name}", @post.fav_string) assert_equal("fav:#{@user.name}", @post.fav_string)
#
# @post.remove_favorite(@user) @post.remove_favorite(@user)
# assert_equal("", @post.fav_string) assert_equal("", @post.fav_string)
# end end
# end end
context "A tag search" do context "A tag search" do
should "return posts for 1 tag" do should "return posts for 1 tag" do