mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 22:27:49 +08:00
FEATURE: Allow excluding uploads from min post length requirement (#31194)
Currently, the markdown for uploads is counted towards post minimum length requirements. This change introduces a site setting `prevent_uploads_only_posts` which can be flipped to exclude upload segments from the calculation.
This commit is contained in:
@ -46,7 +46,7 @@ RSpec.describe PostValidator do
|
||||
end
|
||||
end
|
||||
|
||||
describe "stripped_length" do
|
||||
describe "#stripped_length" do
|
||||
it "adds an error for short raw" do
|
||||
post.raw = "abc"
|
||||
validator.stripped_length(post)
|
||||
@ -103,6 +103,26 @@ RSpec.describe PostValidator do
|
||||
validator.stripped_length(post)
|
||||
expect(post.errors.count).to eq(1)
|
||||
end
|
||||
|
||||
context "when configured to count uploads" do
|
||||
before { SiteSetting.prevent_uploads_only_posts = false }
|
||||
|
||||
it "counts image tags" do
|
||||
post.raw = ""
|
||||
validator.stripped_length(post)
|
||||
expect(post.errors.count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "when configured to not count uploads" do
|
||||
before { SiteSetting.prevent_uploads_only_posts = true }
|
||||
|
||||
it "doesn't count image tags" do
|
||||
post.raw = ""
|
||||
validator.stripped_length(post)
|
||||
expect(post.errors.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "max_posts_validator" do
|
||||
|
Reference in New Issue
Block a user