PERF: Store EmailLog#reply_key as uuid data type.

This commit is contained in:
Guo Xiang Tan
2018-07-17 17:05:04 +08:00
parent 22dad7f0e8
commit 3553375dd2
3 changed files with 26 additions and 12 deletions

View File

@@ -101,19 +101,20 @@ describe EmailLog do
end
end
describe '#bounce_key' do
it 'should format the bounce key correctly' do
bounce_key = SecureRandom.hex
email_log = Fabricate(:email_log, user: user, bounce_key: bounce_key)
%w{reply_key bounce_key}.each do |key|
describe "##{key}" do
it "should format the #{key} correctly" do
hex = SecureRandom.hex
email_log = Fabricate(:email_log, user: user, "#{key}": hex)
raw_bounce_key = EmailLog.where(id: email_log.id)
.pluck("bounce_key::text")
.first
raw_key = EmailLog.where(id: email_log.id)
.pluck("#{key}::text")
.first
expect(raw_bounce_key).to_not eq(bounce_key)
expect(raw_bounce_key.delete('-')).to eq(bounce_key)
expect(EmailLog.find(email_log.id).bounce_key).to eq(bounce_key)
expect(raw_key).to_not eq(hex)
expect(raw_key.delete('-')).to eq(hex)
expect(EmailLog.find(email_log.id).send(key)).to eq(hex)
end
end
end
end