issue3829_broken_avatars_spec.rb 871 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue3829BrokenAvatars, type: :db_migration do
  4. let(:user) { create(:agent) }
  5. let(:avatar) { create(:avatar, o_id: user.id, source_url: source_url) }
  6. context 'when avatar is stored correctly' do
  7. let(:source_url) { 'https://zammad.org/avatar.png' }
  8. before do
  9. user.update(image_source: avatar.source_url)
  10. end
  11. it 'is not removed' do
  12. expect { migrate }.not_to change { Avatar.exists?(id: avatar.id) }
  13. end
  14. end
  15. context 'when avatar is stored without file ending' do
  16. let(:source_url) { 'https://zammad.org/avatar' }
  17. before do
  18. user.update(image_source: avatar.source_url)
  19. end
  20. it 'is removed' do
  21. expect { migrate }.to change { Avatar.exists?(id: avatar.id) }.to(false)
  22. end
  23. end
  24. end