Skip to content

Commit

Permalink
Delete ExplainerItem when ProjectMedia is destroyed. (#1995)
Browse files Browse the repository at this point in the history
Fixes an issue reported by Sentry.

Fixes: CV2-5099.
  • Loading branch information
caiosba authored Aug 18, 2024
1 parent 8400e94 commit fea6cea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/project_media_associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module ProjectMediaAssociations
has_one :claim_description, dependent: :destroy
belongs_to :source, optional: true
has_many :tipline_requests, as: :associated
has_many :explainer_items
has_many :explainer_items, dependent: :destroy
has_many :explainers, through: :explainer_items
has_annotations
end
Expand Down
10 changes: 10 additions & 0 deletions test/models/explainer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,14 @@ def setup
ex.description = 'Now this is the only paragraph'
ex.save!
end

test "should destroy explainer items when project media is destroyed" do
t = create_team
ex = create_explainer team: t
pm = create_project_media team: t
pm.explainers << ex
assert_difference 'ExplainerItem.count', -1 do
pm.destroy!
end
end
end

0 comments on commit fea6cea

Please sign in to comment.