The code powering m.abunchtell.com https://m.abunchtell.com
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

26 rindas
831 B

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe UniqueUsernameValidator do
  4. describe '#validate' do
  5. it 'does not add errors if username is nil' do
  6. account = double(username: nil, persisted?: false, errors: double(add: nil))
  7. subject.validate(account)
  8. expect(account.errors).to_not have_received(:add)
  9. end
  10. it 'does not add errors when existing one is subject itself' do
  11. account = Fabricate(:account, username: 'abcdef')
  12. expect(account).to be_valid
  13. end
  14. it 'adds an error when the username is already used with ignoring cases' do
  15. Fabricate(:account, username: 'ABCdef')
  16. account = double(username: 'abcDEF', persisted?: false, errors: double(add: nil))
  17. subject.validate(account)
  18. expect(account.errors).to have_received(:add)
  19. end
  20. end
  21. end