Fixes #3296 - Channel::EmailParser.process_unprocessable_mails doesn't find matching Group because of key insensitive mismatch in email address.
This commit is contained in:
parent
34ed189881
commit
f851b58062
2 changed files with 58 additions and 1 deletions
|
@ -337,7 +337,7 @@ returns
|
||||||
end
|
end
|
||||||
return if to.blank?
|
return if to.blank?
|
||||||
|
|
||||||
email = EmailAddress.find_by(email: to)
|
email = EmailAddress.find_by(email: to.downcase)
|
||||||
return if email&.channel.blank?
|
return if email&.channel.blank?
|
||||||
|
|
||||||
email.channel&.group
|
email.channel&.group
|
||||||
|
|
|
@ -1357,4 +1357,61 @@ RSpec.describe Channel::EmailParser, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#mail_to_group' do
|
||||||
|
|
||||||
|
context 'when EmailAddress exists' do
|
||||||
|
|
||||||
|
context 'when gives address matches exactly' do
|
||||||
|
|
||||||
|
let(:group) { create(:group) }
|
||||||
|
let(:channel) { create(:email_channel, group: group) }
|
||||||
|
let!(:email_address) { create(:email_address, channel: channel) }
|
||||||
|
|
||||||
|
it 'returns the Channel Group' do
|
||||||
|
expect(described_class.mail_to_group(email_address.email)).to eq(group)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when gives address matches key insensitive' do
|
||||||
|
|
||||||
|
let(:group) { create(:group) }
|
||||||
|
let(:channel) { create(:email_channel, group: group) }
|
||||||
|
let(:address) { 'KeyInsensitive@example.COM' }
|
||||||
|
let!(:email_address) { create(:email_address, email: address, channel: channel) }
|
||||||
|
|
||||||
|
it 'returns the Channel Group' do
|
||||||
|
expect(described_class.mail_to_group(address)).to eq(group)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when no Channel is assigned' do
|
||||||
|
|
||||||
|
let!(:email_address) { create(:email_address, channel: nil) }
|
||||||
|
|
||||||
|
it 'returns nil' do
|
||||||
|
expect(described_class.mail_to_group(email_address.email)).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when Channel has no Group assigned' do
|
||||||
|
|
||||||
|
let(:channel) { create(:email_channel, group: nil) }
|
||||||
|
let!(:email_address) { create(:email_address, channel: channel) }
|
||||||
|
|
||||||
|
it 'returns nil' do
|
||||||
|
expect(described_class.mail_to_group(email_address.email)).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when given address is not parse-able' do
|
||||||
|
|
||||||
|
let(:address) { 'this_is_not_a_valid_email_address' }
|
||||||
|
|
||||||
|
it 'returns nil' do
|
||||||
|
expect(described_class.mail_to_group(address)).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue