From 13c4266c74fb4e86df0d1ef3238761214e908a55 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Sun, 26 May 2013 13:56:42 -0700 Subject: [PATCH] Allow Chinese characters in Topic titles --- lib/text_sentinel.rb | 2 +- spec/components/validators/quality_title_validator_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/text_sentinel.rb b/lib/text_sentinel.rb index 439781b71d5..7c2d818ca2b 100644 --- a/lib/text_sentinel.rb +++ b/lib/text_sentinel.rb @@ -41,7 +41,7 @@ class TextSentinel (@text.gsub(TextSentinel.non_symbols_regexp, '').size > 0) && # Don't allow super long words if there is a word length maximum - (@opts[:max_word_length].blank? || @text.split(/\W/).map(&:size).max <= @opts[:max_word_length] ) && + (@opts[:max_word_length].blank? || @text.split(/\s/).map(&:size).max <= @opts[:max_word_length] ) && # We don't allow all upper case content in english not((@text =~ /[A-Z]+/) && (@text == @text.upcase)) && diff --git a/spec/components/validators/quality_title_validator_spec.rb b/spec/components/validators/quality_title_validator_spec.rb index 0eb22006caa..ba67d61bfc1 100644 --- a/spec/components/validators/quality_title_validator_spec.rb +++ b/spec/components/validators/quality_title_validator_spec.rb @@ -33,6 +33,11 @@ describe "A record validated with QualityTitleValidator" do topic.should be_valid end + it 'allows Chinese characters' do + topic.title = '现在发现使用中文标题没法发帖子了' + topic.should be_valid + end + it "allows anything in a private message" do topic.stubs(:private_message? => true) [short_title, long_title, xxxxx_title].each do |bad_title|