FIX: Don't count draft views towards topic view stats (#28162)

When creating a shared draft, we're recording topic view stats on the draft and then pass those on when the draft is published, conflating the actual view count.

This fixes that by not registering topic views if the topic is a shared draft.
This commit is contained in:
Ted Johansson
2024-07-31 11:10:50 +08:00
committed by GitHub
parent 78f8b7ba99
commit a32390f5dc
4 changed files with 28 additions and 0 deletions

View File

@@ -161,6 +161,20 @@ RSpec.describe Topic do
it { is_expected.to rate_limit }
describe "#shared_draft?" do
fab!(:topic)
context "when topic does not have a shared draft record" do
it { expect(topic).not_to be_shared_draft }
end
context "when topic has a shared draft record" do
before { Fabricate(:shared_draft, topic: topic) }
it { expect(topic).to be_shared_draft }
end
end
describe "#visible_post_types" do
let(:types) { Post.types }