mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: couldn't start a 4-spaces block on the first line of a post
This commit is contained in:
@@ -203,7 +203,7 @@ class PostCreator
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup_post
|
def setup_post
|
||||||
@opts[:raw] = TextCleaner.normalize_whitespaces(@opts[:raw]).strip
|
@opts[:raw] = TextCleaner.normalize_whitespaces(@opts[:raw]).gsub(/\s+\z/, "")
|
||||||
|
|
||||||
post = @topic.posts.new(raw: @opts[:raw],
|
post = @topic.posts.new(raw: @opts[:raw],
|
||||||
user: @user,
|
user: @user,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class PostRevisor
|
|||||||
def revise!(editor, new_raw, opts = {})
|
def revise!(editor, new_raw, opts = {})
|
||||||
@editor = editor
|
@editor = editor
|
||||||
@opts = opts
|
@opts = opts
|
||||||
@new_raw = TextCleaner.normalize_whitespaces(new_raw).strip
|
@new_raw = TextCleaner.normalize_whitespaces(new_raw).gsub(/\s+\z/, "")
|
||||||
|
|
||||||
# TODO this is not in a transaction - dangerous!
|
# TODO this is not in a transaction - dangerous!
|
||||||
return false unless should_revise?
|
return false unless should_revise?
|
||||||
|
|||||||
@@ -468,7 +468,6 @@ describe PostCreator do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
describe "suspended users" do
|
describe "suspended users" do
|
||||||
it "does not allow suspended users to create topics" do
|
it "does not allow suspended users to create topics" do
|
||||||
user = Fabricate(:user, suspended_at: 1.month.ago, suspended_till: 1.month.from_now)
|
user = Fabricate(:user, suspended_at: 1.month.ago, suspended_till: 1.month.from_now)
|
||||||
@@ -479,5 +478,10 @@ describe PostCreator do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't strip starting whitespaces" do
|
||||||
|
post = PostCreator.new(user, { title: "testing whitespace stripping", raw: " <-- whitespaces --> " }).create
|
||||||
|
post.raw.should == " <-- whitespaces -->"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -272,5 +272,12 @@ describe PostRevisor do
|
|||||||
}.to_not change { topic.excerpt }
|
}.to_not change { topic.excerpt }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't strip starting whitespaces" do
|
||||||
|
subject.revise!(post.user, " <-- whitespaces --> ")
|
||||||
|
post.reload
|
||||||
|
post.raw.should == " <-- whitespaces -->"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user