Add minimal test for existing followup search feature
This commit is contained in:
parent
77ae51c914
commit
2da68fa177
2 changed files with 35 additions and 1 deletions
|
@ -134,7 +134,7 @@ returns
|
|||
UserInfo.current_user_id = 1
|
||||
filters = {}
|
||||
Setting.where(area: 'Postmaster::PreFilter').order(:name).each do |setting|
|
||||
filters[setting.name] = Kernel.const_get(Setting.get(setting.name))
|
||||
filters[setting.name] = Setting.get(setting.name).constantize
|
||||
end
|
||||
filters.each do |key, backend|
|
||||
Rails.logger.debug { "run postmaster pre filter #{key}: #{backend}" }
|
||||
|
|
34
spec/models/channel/email_parser_spec.rb
Normal file
34
spec/models/channel/email_parser_spec.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Channel::EmailParser, type: :model do
|
||||
let(:ticket) { create(:ticket) }
|
||||
let(:mail_file) { Rails.root.join('test', 'data', 'mail', 'mail001.box') }
|
||||
let(:raw_mail) { File.read(mail_file).sub(/(?<=^Subject: ).*$/, test_string) }
|
||||
let(:test_string) do
|
||||
Setting.get('ticket_hook') + Setting.get('ticket_hook_divider') + ticket.number
|
||||
end
|
||||
|
||||
describe '#process' do
|
||||
context 'when email subject contains ticket reference' do
|
||||
it 'adds message to ticket' do
|
||||
expect { described_class.new.process({}, raw_mail) }
|
||||
.to change { ticket.articles.length }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when configured to search body' do
|
||||
before { Setting.set('postmaster_follow_up_search_in', 'body') }
|
||||
|
||||
context 'when body contains ticket reference' do
|
||||
context 'in visible text' do
|
||||
let(:raw_mail) { File.read(mail_file).sub(/Hallo =\nMartin,(?=<o:p>)/, test_string) }
|
||||
|
||||
it 'adds message to ticket' do
|
||||
expect { described_class.new.process({}, raw_mail) }
|
||||
.to change { ticket.articles.length }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue