DEV: Delete reviewable associations when deleting (#18472)
This commit is contained in:
parent
e812e10c3b
commit
94aba90c56
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue