Add coverage for account uniqueness

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 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 :active, -> { where(silent: false) }
scope :silent, -> { where(silent: true) } 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(:account).required }
it { is_expected.to belong_to(:status).required } it { is_expected.to belong_to(:status).required }
end end
describe 'Validations' do
subject { Fabricate.build :mention }
it { is_expected.to validate_uniqueness_of(:account_id).scoped_to(:status_id) }
end
end end