FEATURE: Remove full quote only if first paragraph. (#6793)
This commit is contained in:
parent
a313b01148
commit
825ae86857
|
@ -95,7 +95,7 @@ class CookedPostProcessor
|
|||
prev = Post.where('post_number < ? AND topic_id = ? AND post_type = ? AND not hidden', @post.post_number, @post.topic_id, Post.types[:regular]).order('post_number desc').limit(1).pluck(:raw).first
|
||||
return if !prev
|
||||
|
||||
new_raw = @post.raw.gsub(/\[quote[^\]]*\]\s*#{Regexp.quote(prev.strip)}\s*\[\/quote\]/, '')
|
||||
new_raw = @post.raw.gsub(/\A\s*\[quote[^\]]*\]\s*#{Regexp.quote(prev.strip)}\s*\[\/quote\]/, '')
|
||||
return if @post.raw == new_raw
|
||||
|
||||
PostRevisor.new(@post).revise!(
|
||||
|
|
|
@ -1153,6 +1153,7 @@ describe CookedPostProcessor do
|
|||
context "remove direct reply full quote" do
|
||||
let(:topic) { Fabricate(:topic) }
|
||||
let!(:post) { Fabricate(:post, topic: topic, raw: "this is the first post") }
|
||||
|
||||
let(:raw) do
|
||||
<<~RAW
|
||||
[quote="#{post.user.username}, post:#{post.post_number}, topic:#{topic.id}"]
|
||||
|
@ -1163,6 +1164,16 @@ describe CookedPostProcessor do
|
|||
RAW
|
||||
end
|
||||
|
||||
let(:raw2) do
|
||||
<<~RAW
|
||||
and this is the third reply
|
||||
|
||||
[quote="#{post.user.username}, post:#{post.post_number}, topic:#{topic.id}"]
|
||||
this is the first post
|
||||
[/quote]
|
||||
RAW
|
||||
end
|
||||
|
||||
it 'works' do
|
||||
SiteSetting.remove_full_quote = true
|
||||
|
||||
|
@ -1183,6 +1194,15 @@ describe CookedPostProcessor do
|
|||
end
|
||||
end
|
||||
|
||||
it 'does not delete quote if not first paragraph' do
|
||||
SiteSetting.remove_full_quote = true
|
||||
|
||||
reply = Fabricate(:post, topic: topic, raw: raw2)
|
||||
CookedPostProcessor.new(reply).removed_direct_reply_full_quotes
|
||||
expect(topic.posts).to eq([post, reply])
|
||||
expect(reply.raw).to eq(raw2)
|
||||
end
|
||||
|
||||
it "does nothing when 'remove_full_quote' is disabled" do
|
||||
SiteSetting.remove_full_quote = false
|
||||
|
||||
|
|
Loading…
Reference in New Issue