2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-18 16:28:44 +08:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe PostReplyKey do
|
|
|
|
describe "#reply_key" do
|
|
|
|
it "should format the reply_key correctly" do
|
2019-01-10 09:56:03 +08:00
|
|
|
hex = SecureRandom.hex
|
2018-07-18 16:28:44 +08: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-10 09:56:03 +08:00
|
|
|
expect(raw_key).to_not eq(hex)
|
|
|
|
expect(raw_key.delete('-')).to eq(hex)
|
2018-07-18 16:28:44 +08:00
|
|
|
expect(PostReplyKey.find(post_reply_key.id).reply_key).to eq(hex)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|