stopgap measure for #1210
This commit is contained in:
@@ -741,6 +741,15 @@ class PostTest < ActiveSupport::TestCase
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "periodically clean the fav_string" do
|
||||
@post.update_column(:fav_string, "fav:1 fav:1 fav:1")
|
||||
@post.update_column(:fav_count, 3)
|
||||
@post.stubs(:clean_fav_string?).returns(true)
|
||||
@post.append_user_to_fav_string(2)
|
||||
assert_equal("fav:1 fav:2", @post.fav_string)
|
||||
assert_equal(2, @post.fav_count)
|
||||
end
|
||||
|
||||
should "increment the user's favorite_count" do
|
||||
assert_difference("CurrentUser.favorite_count", 1) do
|
||||
@post.add_favorite!(@user)
|
||||
|
||||
@@ -14,6 +14,19 @@ class UserTest < ActiveSupport::TestCase
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "favoriting a post" do
|
||||
setup do
|
||||
@user.update_column(:favorite_count, 999)
|
||||
@user.stubs(:clean_favorite_count?).returns(true)
|
||||
@post = FactoryGirl.create(:post)
|
||||
end
|
||||
|
||||
should "periodically clean the favorite_count" do
|
||||
@user.add_favorite!(@post)
|
||||
assert_equal(1, @user.favorite_count)
|
||||
end
|
||||
end
|
||||
|
||||
context "that has been invited by a mod" do
|
||||
setup do
|
||||
@mod = FactoryGirl.create(:moderator_user)
|
||||
|
||||
Reference in New Issue
Block a user