From 7d43058d20557a7bf7db7f676c1bdd05b5a2c472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Sun, 24 Mar 2013 01:57:00 +0100 Subject: [PATCH] FIX: Email notification for different user being mentioned --- lib/pretty_text.rb | 2 +- spec/models/post_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 212b4d6d9..f0d39b72a 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -65,7 +65,7 @@ module PrettyText @mutex = Mutex.new def self.mention_matcher - /(\@[a-zA-Z0-9\-]+)/ + Regexp.new("(\@[a-zA-Z0-9_]{#{User.username_length.begin},#{User.username_length.end}})") end def self.app_root diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 773478f76..7aba5b9fa 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -216,6 +216,11 @@ describe Post do post.raw_mentions.should == ['finn'] end + it "handles underscore in username" do + post = Fabricate.build(:post, post_args.merge(raw: "@Jake @Finn @Jake_Old")) + post.raw_mentions.should == ['jake', 'finn', 'jake_old'] + end + end context "With a @mention limit of 1" do