Standardize uniqueness validation declaration on Mention (#33247)

This commit is contained in:
Matt Jankowski 2024-12-10 10:45:13 -05:00 committed by GitHub
parent 3222c19d45
commit e76aff7de5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 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

@ -3,8 +3,14 @@
require 'rails_helper'
RSpec.describe Mention do
describe 'validations' do
describe 'Associations' 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