FIX: Delete reviewables associated to posts automatically

Currently we don’t have an association between reviewables and posts.
This sometimes leads to inconsistencies in the DB as a post can have
been deleted but an associated reviewable is still present.

This patch addresses this issue simply by adding a new association to
the `Post` model and by using the `dependent: :destroy` option.
This commit is contained in:
Loïc Guitaut
2023-01-18 17:40:21 +01:00
committed by Loïc Guitaut
parent 82182ec0c7
commit ec2ed5b7f6
3 changed files with 21 additions and 1 deletions

View File

@ -3,9 +3,11 @@
RSpec.describe Post do
fab!(:coding_horror) { Fabricate(:coding_horror) }
let(:upload_path) { Discourse.store.upload_path }
before { Oneboxer.stubs :onebox }
let(:upload_path) { Discourse.store.upload_path }
it { is_expected.to have_many(:reviewables).dependent(:destroy) }
describe "#hidden_reasons" do
context "when verifying enum sequence" do