Add coverage for account uniqueness

pull/32470/head
Matt Jankowski 2024-10-12 19:40:16 -04:00
parent 18deb11585
commit 86872a3681
2 changed files with 7 additions and 1 deletions

View File

@ -18,7 +18,7 @@ class Mention < ApplicationRecord
has_one :notification, as: :activity, dependent: :destroy
validates :account, uniqueness: { scope: :status }
validates :account_id, uniqueness: { scope: :status_id }
scope :active, -> { where(silent: false) }
scope :silent, -> { where(silent: true) }

View File

@ -7,4 +7,10 @@ RSpec.describe Mention do
it { is_expected.to belong_to(:account).required }
it { is_expected.to belong_to(:status).required }
end
describe 'Validations' do
subject { Fabricate.build :mention }
it { is_expected.to validate_uniqueness_of(:account_id).scoped_to(:status_id) }
end
end