mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 14:07:30 +08:00
auto replace rules in titles
This commit is contained in:
@ -5,10 +5,12 @@ require 'text_sentinel'
|
||||
|
||||
describe TextSentinel do
|
||||
|
||||
it "allows utf-8 chars" do
|
||||
TextSentinel.new("йȝîûηыეமிᚉ⠛").text.should == "йȝîûηыეமிᚉ⠛"
|
||||
end
|
||||
|
||||
context "entropy" do
|
||||
|
||||
|
||||
it "returns 0 for an empty string" do
|
||||
TextSentinel.new("").entropy.should == 0
|
||||
end
|
||||
@ -35,50 +37,6 @@ describe TextSentinel do
|
||||
|
||||
end
|
||||
|
||||
context "cleaning up" do
|
||||
|
||||
it "allows utf-8 chars" do
|
||||
TextSentinel.new("йȝîûηыეமிᚉ⠛").text.should == "йȝîûηыეமிᚉ⠛"
|
||||
end
|
||||
|
||||
context "interior spaces" do
|
||||
|
||||
let(:spacey_string) { "hello there's weird spaces here." }
|
||||
let(:unspacey_string) { "hello there's weird spaces here." }
|
||||
|
||||
it "ignores intra spaces by default" do
|
||||
TextSentinel.new(spacey_string).text.should == spacey_string
|
||||
end
|
||||
|
||||
it "fixes intra spaces when enabled" do
|
||||
TextSentinel.new(spacey_string, remove_interior_spaces: true).text.should == unspacey_string
|
||||
end
|
||||
|
||||
it "fixes intra spaces in titles" do
|
||||
TextSentinel.title_sentinel(spacey_string).text.should == unspacey_string
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "stripping whitespace" do
|
||||
let(:spacey_string) { " \t test \t " }
|
||||
let(:unspacey_string) { "test" }
|
||||
|
||||
it "does not strip leading and trailing whitespace by default" do
|
||||
TextSentinel.new(spacey_string).text.should == spacey_string
|
||||
end
|
||||
|
||||
it "strips leading and trailing whitespace when enabled" do
|
||||
TextSentinel.new(spacey_string, strip: true).text.should == unspacey_string
|
||||
end
|
||||
|
||||
it "strips leading and trailing whitespace in titles" do
|
||||
TextSentinel.title_sentinel(spacey_string).text.should == unspacey_string
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "validity" do
|
||||
|
||||
let(:valid_string) { "This is a cool topic about Discourse" }
|
||||
@ -113,8 +71,6 @@ describe TextSentinel do
|
||||
TextSentinel.new("{{$!").should_not be_valid
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user