* FEATURE: Adds site setting to let quotes on direct replies.
* DEV: Added test. * FIX: Do not bump topic when removing full quotes.
This commit is contained in:
parent
dbbadb5c35
commit
7cac04e1a8
|
@ -1308,6 +1308,7 @@ en:
|
|||
send_tl1_welcome_message: "Send new trust level 1 users a welcome message."
|
||||
suppress_reply_directly_below: "Don't show the expandable reply count on a post when there is only a single reply directly below this post."
|
||||
suppress_reply_directly_above: "Don't show the expandable in-reply-to on a post when there is only a single reply directly above this post."
|
||||
remove_full_quote: "Automatically remove full quotes on direct replies."
|
||||
suppress_reply_when_quoting: "Don't show the expandable in-reply-to on a post when post quotes reply."
|
||||
max_reply_history: "Maximum number of replies to expand when expanding in-reply-to"
|
||||
topics_per_period_in_top_summary: "Number of top topics shown in the default top topics summary."
|
||||
|
|
|
@ -675,6 +675,8 @@ posting:
|
|||
default: true
|
||||
suppress_reply_when_quoting:
|
||||
default: true
|
||||
remove_full_quote:
|
||||
default: true
|
||||
max_reply_history:
|
||||
default: 1
|
||||
client: true
|
||||
|
|
|
@ -87,7 +87,7 @@ class CookedPostProcessor
|
|||
end
|
||||
|
||||
def removed_direct_reply_full_quotes
|
||||
return if @post.post_number == 1
|
||||
return if !SiteSetting.remove_full_quote || @post.post_number == 1
|
||||
|
||||
num_quotes = @doc.css("aside.quote").size
|
||||
return if num_quotes != 1
|
||||
|
@ -104,7 +104,8 @@ class CookedPostProcessor
|
|||
raw: new_raw.strip,
|
||||
edit_reason: I18n.t(:removed_direct_reply_full_quotes)
|
||||
},
|
||||
skip_validations: true
|
||||
skip_validations: true,
|
||||
bypass_bump: true
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -1146,28 +1146,44 @@ 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}"]
|
||||
this is the first post
|
||||
[/quote]
|
||||
|
||||
and this is the third reply
|
||||
RAW
|
||||
end
|
||||
|
||||
it 'works' do
|
||||
post = Fabricate(:post, topic: topic, raw: "this is the first post")
|
||||
hidden = Fabricate(:post, topic: topic, hidden: true, raw: "this is the second post")
|
||||
small_action = Fabricate(:post, topic: topic, post_type: Post.types[:small_action])
|
||||
raw = <<~RAW
|
||||
[quote="#{post.user.username}, post:#{post.post_number}, topic:#{topic.id}"]
|
||||
this is the first post
|
||||
[/quote]
|
||||
SiteSetting.remove_full_quote = true
|
||||
|
||||
and this is the third reply
|
||||
RAW
|
||||
hidden = Fabricate(:post, topic: topic, hidden: true, raw: "this is the second post after")
|
||||
small_action = Fabricate(:post, topic: topic, post_type: Post.types[:small_action])
|
||||
reply = Fabricate(:post, topic: topic, raw: raw)
|
||||
|
||||
cpp = CookedPostProcessor.new(reply)
|
||||
cpp.removed_direct_reply_full_quotes
|
||||
freeze_time Time.zone.now do
|
||||
topic.bumped_at = 1.day.ago
|
||||
CookedPostProcessor.new(reply).removed_direct_reply_full_quotes
|
||||
|
||||
expect(topic.posts).to eq([post, hidden, small_action, reply])
|
||||
expect(reply.raw).to eq("and this is the third reply")
|
||||
expect(reply.revisions.count).to eq(1)
|
||||
expect(reply.revisions.first.modifications["raw"]).to eq([raw, reply.raw])
|
||||
expect(reply.revisions.first.modifications["edit_reason"][1]).to eq(I18n.t(:removed_direct_reply_full_quotes))
|
||||
expect(topic.posts).to eq([post, hidden, small_action, reply])
|
||||
expect(topic.bumped_at).to eq(1.day.ago)
|
||||
expect(reply.raw).to eq("and this is the third reply")
|
||||
expect(reply.revisions.count).to eq(1)
|
||||
expect(reply.revisions.first.modifications["raw"]).to eq([raw, reply.raw])
|
||||
expect(reply.revisions.first.modifications["edit_reason"][1]).to eq(I18n.t(:removed_direct_reply_full_quotes))
|
||||
end
|
||||
end
|
||||
|
||||
it "does nothing when 'remove_full_quote' is disabled" do
|
||||
SiteSetting.remove_full_quote = false
|
||||
|
||||
reply = Fabricate(:post, topic: topic, raw: raw)
|
||||
|
||||
CookedPostProcessor.new(reply).removed_direct_reply_full_quotes
|
||||
expect(reply.raw).to eq(raw)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue