mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-02-02 04:52:54 -05:00
Don't save mute notes if the note is blank (#193)
This commit is contained in:
parent
27f8d2c739
commit
1704e0066a
@ -13,5 +13,7 @@
|
||||
class Glitch::Note < ApplicationRecord
|
||||
belongs_to :target, polymorphic: true
|
||||
|
||||
validates :note, presence: true
|
||||
|
||||
alias_attribute :text, :note
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ class MuteService < BaseService
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
mute = account.mute!(target_account, notifications: notifications)
|
||||
mute.create_note!(note: note) if note
|
||||
mute.create_note!(note: note) if !note.blank?
|
||||
BlockWorker.perform_async(account.id, target_account.id)
|
||||
mute
|
||||
end
|
||||
|
@ -64,4 +64,18 @@ RSpec.describe MuteService do
|
||||
}.from(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a note string' do
|
||||
it 'adds a note to the mute' do
|
||||
mute = described_class.new.call(account, target_account, note: 'Too many jorts')
|
||||
note = mute.note
|
||||
expect(note.text).to eq('Too many jorts')
|
||||
end
|
||||
|
||||
it 'does not add a note if the note is blank' do
|
||||
mute = described_class.new.call(account, target_account, note: ' ')
|
||||
note = mute.note
|
||||
expect(note).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user