From 876a570e3a2e227528d135a0cc67cccf442baaf1 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 17 Jun 2013 12:22:23 -0400 Subject: [PATCH] Fix to prevent check for all upper case for non-ascii messages --- lib/text_sentinel.rb | 2 +- spec/components/text_sentinel_spec.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/text_sentinel.rb b/lib/text_sentinel.rb index f4361ebfb..73e075fbc 100644 --- a/lib/text_sentinel.rb +++ b/lib/text_sentinel.rb @@ -66,7 +66,7 @@ class TextSentinel def seems_quiet? # We don't allow all upper case content in english - not((@text =~ /[A-Z]+/) && (@text == @text.upcase)) + not((@text =~ /[A-Z]+/) && !(@text =~ /[^[:ascii:]]/) && (@text == @text.upcase)) end end diff --git a/spec/components/text_sentinel_spec.rb b/spec/components/text_sentinel_spec.rb index 669dc837f..15275e25a 100644 --- a/spec/components/text_sentinel_spec.rb +++ b/spec/components/text_sentinel_spec.rb @@ -45,6 +45,23 @@ describe TextSentinel do end + context 'body_sentinel' do + [ 'evil trout is evil', + "去年十社會警告", + "P.S. Пробирочка очень толковая и весьма умная, так что не обнимайтесь.", + "LOOK: 去年十社會警告" + ].each do |valid_body| + it "handles a valid body in a private message" do + expect(TextSentinel.body_sentinel(valid_body, private_message: true)).to be_valid + end + + it "handles a valid body in a public post" do + expect(TextSentinel.body_sentinel(valid_body, private_message: false)).to be_valid + end + end + + end + context "validity" do let(:valid_string) { "This is a cool topic about Discourse" }