Fix nil handling regression from #2152 fix
This commit is contained in:
parent
9e124593b6
commit
19319d9d83
2 changed files with 15 additions and 1 deletions
|
@ -43,7 +43,7 @@ module Import
|
|||
end
|
||||
|
||||
def display_path(folder)
|
||||
display_name = folder.display_name.utf8_encode(fallback: :read_as_sanitized_binary)
|
||||
display_name = folder.display_name&.utf8_encode(fallback: :read_as_sanitized_binary)
|
||||
parent_folder = find(folder.parent_folder_id)
|
||||
|
||||
return display_name if parent_folder.blank?
|
||||
|
|
|
@ -10,6 +10,20 @@ RSpec.describe Import::Exchange::Folder do
|
|||
let(:child_folder) { double('EWS Folder') }
|
||||
let(:exception_case) { double('EWS Folder') }
|
||||
|
||||
context 'when folder.display_name returns nil' do
|
||||
before do
|
||||
allow(root_folder).to receive(:display_name).and_return(nil)
|
||||
allow(root_folder).to receive(:parent_folder_id).and_return(nil)
|
||||
|
||||
allow(subject).to receive(:find).with(any_args).and_return(root_folder)
|
||||
allow(subject).to receive(:find).with(nil).and_return(nil)
|
||||
end
|
||||
|
||||
it 'returns nil' do
|
||||
expect(subject.display_path(root_folder)).to be(nil)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when server returns valid UTF-8' do
|
||||
before do
|
||||
allow(root_folder).to receive(:display_name).and_return('Root')
|
||||
|
|
Loading…
Reference in a new issue