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 3a9b9fddf2..67c22b5d1f 100644 --- a/spec/models/mention_spec.rb +++ b/spec/models/mention_spec.rb @@ -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