The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
1.3 KiB

  1. # frozen_string_literal: true
  2. shared_examples 'AccountAvatar' do |fabricator|
  3. describe 'static avatars' do
  4. describe 'when GIF' do
  5. it 'creates a png static style' do
  6. account = Fabricate(fabricator, avatar: attachment_fixture('avatar.gif'))
  7. expect(account.avatar_static_url).to_not eq account.avatar_original_url
  8. end
  9. end
  10. describe 'when non-GIF' do
  11. it 'does not create extra static style' do
  12. account = Fabricate(fabricator, avatar: attachment_fixture('attachment.jpg'))
  13. expect(account.avatar_static_url).to eq account.avatar_original_url
  14. end
  15. end
  16. end
  17. describe 'base64-encoded files' do
  18. let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" }
  19. let(:account) { Fabricate(fabricator, avatar: base64_attachment) }
  20. it 'saves avatar' do
  21. expect(account.persisted?).to be true
  22. expect(account.avatar).to_not be_nil
  23. end
  24. it 'gives the avatar a file name' do
  25. expect(account.avatar_file_name).to_not be_blank
  26. end
  27. it 'saves a new avatar under a different file name' do
  28. previous_file_name = account.avatar_file_name
  29. account.update(avatar: base64_attachment)
  30. expect(account.avatar_file_name).to_not eq previous_file_name
  31. end
  32. end
  33. end