2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2018-07-11 09:01:54 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe HttpLog do
|
2021-09-22 06:53:16 +00:00
|
|
|
subject(:http_log) { build(:http_log) }
|
2018-07-11 09:01:54 +00:00
|
|
|
|
|
|
|
describe 'callbacks' do
|
|
|
|
# See https://github.com/zammad/zammad/issues/2100
|
|
|
|
it 'converts request/response message data to UTF-8 before saving' do
|
2021-09-22 06:53:16 +00:00
|
|
|
http_log.request[:content] = 'foo'.force_encoding('ascii-8bit')
|
|
|
|
http_log.response[:content] = 'bar'.force_encoding('ascii-8bit')
|
2018-07-11 09:01:54 +00:00
|
|
|
|
2021-09-22 06:53:16 +00:00
|
|
|
expect { http_log.save }
|
|
|
|
.to change { http_log.request[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8')
|
|
|
|
.and change { http_log.response[:content].encoding.name }.from('ASCII-8BIT').to('UTF-8')
|
2018-07-11 09:01:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|