From 86872a36811ea259f9d00fbca6ad0d7d2f7cb352 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 12 Oct 2024 19:40:16 -0400 Subject: [PATCH] Add coverage for account uniqueness --- app/models/mention.rb | 2 +- spec/models/mention_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/mention.rb b/app/models/mention.rb index a508ed630e..e921d41de3 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -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) } diff --git a/spec/models/mention_spec.rb b/spec/models/mention_spec.rb index 404c424540..67c22b5d1f 100644 --- a/spec/models/mention_spec.rb +++ b/spec/models/mention_spec.rb @@ -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