From 770ace0e682f202300cf08eacf72eef96bd46a55 Mon Sep 17 00:00:00 2001 From: albert Date: Mon, 18 Mar 2013 12:41:33 -0700 Subject: [PATCH] fix tests, implement limits for favorites --- app/models/post.rb | 1 - app/models/user.rb | 16 +++++++--------- test/unit/post_test.rb | 8 ++++---- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 712139b7e..bff6fec83 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -782,7 +782,6 @@ class Post < ActiveRecord::Base update_parent_on_destroy # decrement_tag_post_counts update_column(:parent_id, nil) - Post.expire_cache_for_all(tag_array) unless options[:without_mod_action] ModAction.create(:description => "deleted post ##{id}") diff --git a/app/models/user.rb b/app/models/user.rb index c8e953145..f454cd7b1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -461,15 +461,13 @@ class User < ActiveRecord::Base end def favorite_limit - return nil - - # if is_privileged? - # 20_000 - # elsif is_platinum? - # nil - # else - # 4_000 - # end + if is_privileged? + 20_000 + elsif is_platinum? + nil + else + 4_000 + end end end diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 759090b81..6b048d866 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -61,8 +61,8 @@ class PostTest < ActiveSupport::TestCase assert_equal(1, Post.fast_count) assert_equal(1, Post.fast_count("aaa")) post.delete! - assert_equal(0, Post.fast_count) - assert_equal(0, Post.fast_count("aaa")) + assert_equal(1, Post.fast_count) + assert_equal(1, Post.fast_count("aaa")) end should "toggle the is_deleted flag" do @@ -72,11 +72,11 @@ class PostTest < ActiveSupport::TestCase assert_equal(true, post.is_deleted?) end - should "decrement the tag counts" do + should "not decrement the tag counts" do post = FactoryGirl.create(:post, :tag_string => "aaa") assert_equal(1, Tag.find_by_name("aaa").post_count) post.delete! - assert_equal(0, Tag.find_by_name("aaa").post_count) + assert_equal(1, Tag.find_by_name("aaa").post_count) end end end