2018-07-18 04:28:44 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe PostReplyKey do
|
|
|
|
describe "#reply_key" do
|
|
|
|
it "should format the reply_key correctly" do
|
2019-01-09 20:56:03 -05:00
|
|
|
hex = SecureRandom.hex
|
2018-07-18 04:28:44 -04:00
|
|
|
post_reply_key = Fabricate(:post_reply_key,
|
|
|
|
reply_key: hex
|
|
|
|
)
|
|
|
|
|
|
|
|
raw_key = PostReplyKey.where(id: post_reply_key.id)
|
|
|
|
.pluck("reply_key::text")
|
|
|
|
.first
|
|
|
|
|
2019-01-09 20:56:03 -05:00
|
|
|
expect(raw_key).to_not eq(hex)
|
|
|
|
expect(raw_key.delete('-')).to eq(hex)
|
2018-07-18 04:28:44 -04:00
|
|
|
expect(PostReplyKey.find(post_reply_key.id).reply_key).to eq(hex)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|