http_log_spec.rb 709 B

12345678910111213141516171819
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe HttpLog do
  4. subject(:http_log) { build(:http_log) }
  5. describe 'callbacks' do
  6. # See https://github.com/zammad/zammad/issues/2100
  7. it 'converts request/response message data to UTF-8 before saving' do
  8. http_log.request[:content] = 'foo'.force_encoding('ascii-8bit')
  9. http_log.response[:content] = 'bar'.force_encoding('ascii-8bit')
  10. expect { http_log.save }
  11. .to change { http_log.request[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8')
  12. .and change { http_log.response[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8')
  13. end
  14. end
  15. end