diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-08-01 10:06:28 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-08-01 10:06:28 +0100 |
commit | 38029517f95d42539dad12db748b789574a8207b (patch) | |
tree | f0213460bce04168ee855770c4bbb35bb5fff047 | |
parent | ba01cc9a8b8dd6edf1e1017d170f2b71a3f93473 (diff) |
User's display name should indicate if they've been banned. Fixes #100.
-rw-r--r-- | app/models/user.rb | 3 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index e29ae3101..fddb6b035 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -118,6 +118,9 @@ class User < ActiveRecord::Base if not name.nil? name.strip! end + if self.public_banned? + name = _("{{user_name}} (Banned)", :user_name=>name) + end name end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c913ce3a8..ee6916ffc 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -15,6 +15,24 @@ describe User, "making up the URL name" do @user.url_name.should == 'user' end end + + +describe User, "showing the name" do + before do + @user = User.new + @user.name = 'Some Name ' + end + + it 'should strip whitespace' do + @user.name.should == 'Some Name' + end + + it 'should show if user has been banned' do + @user.ban_text = "Naughty user" + @user.name.should == 'Some Name (Banned)' + end + +end describe User, " when authenticating" do before do |