mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-23 16:44:04 -05:00
Cascade mute/block destruction to notes (#193)
This commit is contained in:
parent
2ce4af84e9
commit
1b3ff6a92f
@ -21,7 +21,7 @@ class Block < ApplicationRecord
|
||||
after_create :remove_blocking_cache
|
||||
after_destroy :remove_blocking_cache
|
||||
|
||||
has_one :note, class_name: 'Glitch::Note', as: :target
|
||||
has_one :note, class_name: 'Glitch::Note', as: :target, dependent: :destroy
|
||||
|
||||
private
|
||||
|
||||
|
@ -22,7 +22,7 @@ class Mute < ApplicationRecord
|
||||
after_create :remove_blocking_cache
|
||||
after_destroy :remove_blocking_cache
|
||||
|
||||
has_one :note, class_name: 'Glitch::Note', as: :target
|
||||
has_one :note, class_name: 'Glitch::Note', as: :target, dependent: :destroy
|
||||
|
||||
private
|
||||
|
||||
|
@ -44,4 +44,12 @@ RSpec.describe Block, type: :model do
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to eq false
|
||||
expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to eq false
|
||||
end
|
||||
|
||||
it 'removes associated note after destruction' do
|
||||
block = Fabricate(:block)
|
||||
block.create_note!(note: 'Too many oats')
|
||||
block.destroy!
|
||||
|
||||
expect(Glitch::Note.count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Mute, type: :model do
|
||||
subject { Fabricate(:mute) }
|
||||
|
||||
describe '#destroy' do
|
||||
it 'destroys associated notes' do
|
||||
subject.create_note!(note: 'Too many jorts')
|
||||
subject.destroy!
|
||||
|
||||
expect(Glitch::Note.count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user