A platform for community discussion. Free, open, simple.
FIX: Only likes should change the given daily likes
Gerhard Schlager5ca58179029d
diff --git a/app/models/post_action.rb b/app/models/post_action.rbindex 8bcb64482b3..cc3096272c2 100644--- a/app/models/post_action.rb+++ b/app/models/post_action.rb@@ -302,7 +302,8 @@ SQLBadgeGranter.queue_badge_grant(Badge::Trigger::PostAction, post_action: post_action)endend- GivenDailyLike.increment_for(user.id)++ GivenDailyLike.increment_for(user.id) if post_action_type_id == PostActionType.types[:like]# agree with other flagsif staff_took_action@@ -339,7 +340,7 @@ SQLif action = finder.firstaction.remove_act!(user)action.post.unhide! if action.staff_took_action- GivenDailyLike.decrement_for(user.id)+ GivenDailyLike.decrement_for(user.id) if post_action_type_id == PostActionType.types[:like]endenddiff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rbindex b22abb3b199..f17d1f79865 100644--- a/spec/models/post_action_spec.rb+++ b/spec/models/post_action_spec.rb@@ -276,6 +276,26 @@ describe PostAction doexpect(post.like_count).to eq(0)expect(post.like_score).to eq(0)end++ it "shouldn't change given_likes unless likes are given or removed" do+ freeze_time(Time.zone.now)++ PostAction.act(codinghorror, Fabricate(:post), PostActionType.types[:like])+ expect(value_for(codinghorror.id, Date.today)).to eq(1)++ PostActionType.types.each do |type_name, type_id|+ post = Fabricate(:post)++ PostAction.act(codinghorror, post, type_id)+ actual_count = value_for(codinghorror.id, Date.today)+ expected_count = type_name == :like ? 2 : 1+ expect(actual_count).to eq(expected_count), "Expected likes_given to be #{expected_count} when adding '#{type_name}', but got #{actual_count}"++ PostAction.remove_act(codinghorror, post, type_id)+ actual_count = value_for(codinghorror.id, Date.today)+ expect(actual_count).to eq(1), "Expected likes_given to be 1 when removing '#{type_name}', but got #{actual_count}"+ end+ endenddescribe "undo/redo repeatedly" do