2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2014-07-15 15:47:24 +08:00
|
|
|
|
|
|
|
describe QuotedPost do
|
|
|
|
it 'correctly extracts quotes in integration test' do
|
|
|
|
post1 = create_post
|
|
|
|
post2 = create_post(topic_id: post1.topic_id,
|
2014-09-25 23:44:48 +08:00
|
|
|
raw: "[quote=\"#{post1.user.username}, post: 1, topic:#{post1.topic_id}\"]\ntest\n[/quote]\nthis is a test post",
|
2014-07-31 09:38:03 +08:00
|
|
|
reply_to_post_number: 1)
|
2014-07-15 15:47:24 +08:00
|
|
|
|
2015-01-06 00:04:23 +08:00
|
|
|
expect(QuotedPost.find_by(post_id: post2.id, quoted_post_id: post1.id)).not_to eq(nil)
|
|
|
|
expect(post2.reply_quoted).to eq(true)
|
2014-07-15 15:47:24 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'correctly handles deltas' do
|
|
|
|
post1 = Fabricate(:post)
|
|
|
|
post2 = Fabricate(:post)
|
|
|
|
|
2016-12-01 00:18:34 +08:00
|
|
|
post2.cooked = <<-HTML
|
|
|
|
<aside class="quote" data-post="#{post1.post_number}" data-topic="#{post1.topic_id}">
|
|
|
|
<div class="title">
|
|
|
|
<div class="quote-controls"></div>
|
|
|
|
<img width="20" height="20" src="/user_avatar/meta.discourse.org/techapj/20/3281.png" class="avatar">techAPJ:
|
|
|
|
</div>
|
|
|
|
<blockquote><p>When the user will v</p></blockquote>
|
|
|
|
</aside>
|
|
|
|
HTML
|
2014-07-15 15:47:24 +08:00
|
|
|
|
|
|
|
QuotedPost.create!(post_id: post2.id, quoted_post_id: 999)
|
|
|
|
|
|
|
|
QuotedPost.extract_from(post2)
|
2015-01-06 00:04:23 +08:00
|
|
|
expect(QuotedPost.where(post_id: post2.id).count).to eq(1)
|
|
|
|
expect(QuotedPost.find_by(post_id: post2.id, quoted_post_id: post1.id)).not_to eq(nil)
|
2014-07-15 15:47:24 +08:00
|
|
|
|
2015-01-06 00:04:23 +08:00
|
|
|
expect(post2.reply_quoted).to eq(false)
|
2014-07-15 15:47:24 +08:00
|
|
|
end
|
|
|
|
end
|