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

* FIX: flaky specs after topic view custom filters

When ensuring TopicView class variables return to the original state it should use empty Hash instead of empty Array. That

https://github.com/discourse/discourse/blob/master/lib/topic_view.rb#L60

* FIX: convert to string for topic view custom filter
This commit is contained in:
Krzysztof Kotlarek 2021-05-11 11:24:14 +10:00 committed by GitHub
parent 37812b8e35
commit 4a2912233c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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