Fix list creation limit check (#32869)

pull/2898/head
Claire 2024-11-13 11:22:11 +01:00 committed by GitHub
parent 95d7120ce6
commit 8f5cbf5370
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class List < ApplicationRecord
private
def validate_account_lists_limit
errors.add(:base, I18n.t('lists.errors.limit')) if account.lists.count >= PER_ACCOUNT_LIMIT
errors.add(:base, I18n.t('lists.errors.limit')) if account.owned_lists.count >= PER_ACCOUNT_LIMIT
end
def clean_feed_manager

View File

@ -11,7 +11,11 @@ RSpec.describe List do
context 'when account has hit max list limit' do
let(:account) { Fabricate :account }
before { stub_const 'List::PER_ACCOUNT_LIMIT', 0 }
before do
stub_const 'List::PER_ACCOUNT_LIMIT', 1
Fabricate(:list, account: account)
end
context 'when creating a new list' do
it { is_expected.to_not allow_value(account).for(:account).against(:base).with_message(I18n.t('lists.errors.limit')) }