Skip to content

A platform for community discussion. Free, open, simple.

FIX: flaky specs after topic view custom filters (#13019)

Krzysztof Kotlarek4a2912233c28
diff --git a/lib/topic_view.rb b/lib/topic_view.rb
index d56b064c06a..dcdec084bc7 100644
--- a/lib/topic_view.rb
+++ b/lib/topic_view.rb
@@ -781,7 +781,7 @@ class TopicView
@contains_gaps = true
end
- if @filter.present? && @filter != 'summary' && TopicView.custom_filters[@filter].present?
+ if @filter.present? && @filter.to_s != 'summary' && TopicView.custom_filters[@filter].present?
@filtered_posts = TopicView.custom_filters[@filter].call(@filtered_posts, self)
end
diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb
index 9db72fd9f90..c4a104cd23e 100644
--- a/spec/components/topic_view_spec.rb
+++ b/spec/components/topic_view_spec.rb
@@ -74,7 +74,7 @@ describe TopicView do
expect(tv.filter_posts).to eq([p0, p1])
ensure
- TopicView.instance_variable_set(:@custom_filters, [])
+ TopicView.instance_variable_set(:@custom_filters, {})
end
end
diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb
index 68a010f6f16..cfb00692221 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -2456,7 +2456,7 @@ RSpec.describe TopicsController do
expect(body["post_stream"]["posts"].map { |p| p["id"] }).to eq([post3.id])
ensure
- TopicView.instance_variable_set(:@custom_filters, [])
+ TopicView.instance_variable_set(:@custom_filters, {})
end
end
end