2014-07-15 03:47:24 -04:00
require 'spec_helper'
describe QuotedPost do
it 'correctly extracts quotes in integration test' do
post1 = create_post
post2 = create_post ( topic_id : post1 . topic_id ,
2014-07-30 21:38:03 -04:00
raw : " [quote= \" #{ post1 . user . username } , post: 1, topic: #{ post1 . topic_id } \" ] \n test \n [/quote] \n this is a test post " ,
reply_to_post_number : 1 )
2014-07-15 03:47:24 -04:00
QuotedPost . find_by ( post_id : post2 . id , quoted_post_id : post1 . id ) . should_not be_nil
2014-07-30 21:38:03 -04:00
post2 . reply_quoted . should == true
2014-07-15 03:47:24 -04:00
end
it 'correctly handles deltas' do
post1 = Fabricate ( :post )
post2 = Fabricate ( :post )
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=" /use r_avatar / meta . discourse . org / techapj / 20 / 3281 . png " class= " avatar " >techAPJ said:</div><blockquote><p>When the user will v</p></blockquote></aside>
HTML
QuotedPost . create! ( post_id : post2 . id , quoted_post_id : 999 )
QuotedPost . extract_from ( post2 )
QuotedPost . where ( post_id : post2 . id ) . count . should == 1
QuotedPost . find_by ( post_id : post2 . id , quoted_post_id : post1 . id ) . should_not be_nil
2014-07-30 21:38:03 -04:00
post2 . reply_quoted . should == false
2014-07-15 03:47:24 -04:00
end
end