A platform for community discussion. Free, open, simple.
FIX: flaky post action counts specs (#27165)
Krzysztof Kotlareka4c5f85b10ea
diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rbindex e5efff27707..1c575b1dc60 100644--- a/app/serializers/post_serializer.rb+++ b/app/serializers/post_serializer.rb@@ -331,7 +331,7 @@ class PostSerializer < BasicPostSerializersummary[:count] = summary[:acted] ? 1 : 0end- summary.delete(:count) if summary[:count] == 0+ summary.delete(:count) if summary[:count].to_i.zero?# Only include it if the user can do it or it has a countresult << summary if summary[:can_act] || summary[:count]diff --git a/spec/models/flag_spec.rb b/spec/models/flag_spec.rbindex 9f384d947e8..ff26f05d474 100644--- a/spec/models/flag_spec.rb+++ b/spec/models/flag_spec.rb@@ -1,7 +1,11 @@# frozen_string_literal: trueRSpec.describe Flag, type: :model do- before { Flag.reset_flag_settings! }+ around do |test|+ Flag.reset_flag_settings!+ test.call+ Flag.reset_flag_settings!+ endit "has id lower than 1000 for system flags" doflag = Fabricate(:flag, id: 1)