From 8f5cbf537026915215d84945efad9a878ac8cdb4 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 13 Nov 2024 11:22:11 +0100 Subject: [PATCH] Fix list creation limit check (#32869) --- app/models/list.rb | 2 +- spec/models/list_spec.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/list.rb b/app/models/list.rb index d4915f56fae..bb7dd4cfc01 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -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 diff --git a/spec/models/list_spec.rb b/spec/models/list_spec.rb index 62a84dfebf2..48c273d3ecb 100644 --- a/spec/models/list_spec.rb +++ b/spec/models/list_spec.rb @@ -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')) }