mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 17:35:40 +01:00
Standardize uniqueness validation declaration on Mention
(#33247)
This commit is contained in:
parent
3222c19d45
commit
e76aff7de5
2 changed files with 8 additions and 2 deletions
|
@ -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) }
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue