From d95172cb5d4aaee04849b79b3cd7d8d145c778db Mon Sep 17 00:00:00 2001 From: Nathan Nontell Date: Mon, 16 Sep 2013 09:45:57 -0400 Subject: [PATCH] Allow TextSentinel#seems_unpretentious? to accept words joined with dashes or forward slashes. (Issue 1133) --- lib/text_sentinel.rb | 2 +- spec/components/text_sentinel_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/text_sentinel.rb b/lib/text_sentinel.rb index e7a6b3b3339..e59bc327637 100644 --- a/lib/text_sentinel.rb +++ b/lib/text_sentinel.rb @@ -67,7 +67,7 @@ class TextSentinel def seems_unpretentious? # Don't allow super long words if there is a word length maximum - @opts[:max_word_length].blank? || @text.split(/\s/).map(&:size).max <= @opts[:max_word_length] + @opts[:max_word_length].blank? || @text.split(/\s|\/|-/).map(&:size).max <= @opts[:max_word_length] end diff --git a/spec/components/text_sentinel_spec.rb b/spec/components/text_sentinel_spec.rb index 8c3ca4bc45a..5c6f903fa66 100644 --- a/spec/components/text_sentinel_spec.rb +++ b/spec/components/text_sentinel_spec.rb @@ -96,6 +96,14 @@ describe TextSentinel do TextSentinel.new("{{$!").should_not be_valid end + it "does allow a long alphanumeric string joined with slashes" do + TextSentinel.new("gdfgdfgdfg/fgdfgdfgdg/dfgdfgdfgd/dfgdfgdfgf", max_word_length: 30).should be_valid + end + + it "does allow a long alphanumeric string joined with dashes" do + TextSentinel.new("gdfgdfgdfg-fgdfgdfgdg-dfgdfgdfgd-dfgdfgdfgf", max_word_length: 30).should be_valid + end + end context 'title_sentinel' do