DEV: Delete reviewable associations when deleting (#18472)

This commit is contained in:
Roman Rizzi 2022-10-05 13:38:41 -03:00 committed by GitHub
parent e812e10c3b
commit 94aba90c56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -28,8 +28,8 @@ class Reviewable < ActiveRecord::Base
belongs_to :topic
belongs_to :category
has_many :reviewable_histories
has_many :reviewable_scores, -> { order(created_at: :desc) }
has_many :reviewable_histories, dependent: :destroy
has_many :reviewable_scores, -> { order(created_at: :desc) }, dependent: :destroy
enum :status, {
pending: 0,

View File

@ -7,6 +7,9 @@ RSpec.describe Reviewable, type: :model do
let(:reviewable) { Fabricate.build(:reviewable, created_by: admin) }
it { is_expected.to have_many(:reviewable_scores).dependent(:destroy) }
it { is_expected.to have_many(:reviewable_histories).dependent(:destroy) }
it "can create a reviewable object" do
expect(reviewable).to be_present
expect(reviewable.pending?).to eq(true)