mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-03 12:29:26 +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
|
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) }
|
||||||
|
|
|
@ -3,8 +3,14 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Mention do
|
RSpec.describe Mention do
|
||||||
describe 'validations' do
|
describe 'Associations' 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
|
||||||
|
|
Loading…
Reference in a new issue