mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 02:34:28 +08:00
DEV: cleanup custom filters to prevent leaks
Ensures we clean up any custom filters added in the specs to prevent any leaks when running the specs. Follow up to https://github.com/discourse/discourse/pull/26770#discussion_r1582464760
This commit is contained in:
@ -3336,6 +3336,9 @@ RSpec.describe TopicsController do
|
||||
describe "custom filters" do
|
||||
fab!(:post2) { Fabricate(:post, user: post_author2, topic: topic, percent_rank: 0.2) }
|
||||
fab!(:post3) { Fabricate(:post, user: post_author3, topic: topic, percent_rank: 0.5) }
|
||||
|
||||
after { TopicView.custom_filters.clear }
|
||||
|
||||
it "should return the right posts" do
|
||||
TopicView.add_custom_filter("percent") do |posts, topic_view|
|
||||
posts.where(percent_rank: 0.5)
|
||||
@ -3348,8 +3351,6 @@ RSpec.describe TopicsController do
|
||||
body = response.parsed_body
|
||||
|
||||
expect(body["post_stream"]["posts"].map { |p| p["id"] }).to eq([post3.id])
|
||||
ensure
|
||||
TopicView.instance_variable_set(:@custom_filters, {})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user