1
0

list_spec.rb 807 B

12345678910111213141516171819202122232425262728293031
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe List do
  4. describe 'Validations' do
  5. subject { Fabricate.build :list }
  6. it { is_expected.to validate_presence_of(:title) }
  7. context 'when account has hit max list limit' do
  8. let(:account) { Fabricate :account }
  9. before do
  10. stub_const 'List::PER_ACCOUNT_LIMIT', 1
  11. Fabricate(:list, account: account)
  12. end
  13. context 'when creating a new list' do
  14. it { is_expected.to_not allow_value(account).for(:account).against(:base).with_message(I18n.t('lists.errors.limit')) }
  15. end
  16. context 'when updating an existing list' do
  17. before { subject.save(validate: false) }
  18. it { is_expected.to allow_value(account).for(:account).against(:base) }
  19. end
  20. end
  21. end
  22. end