From 774b8d159c8095977148cc2f6d7902c2636cccbd Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 28 May 2013 11:18:12 +0100 Subject: Return a string from user.name always to avoid any complications with other functions calling gsub on the result. SafeBuffer won't work with gsub until Rails 3.2 https://github.com/rails/rails/commit/b4a6e2f8442ceda118367f9a61c38af754be1cbf --- spec/models/user_spec.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'spec/models/user_spec.rb') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e31c3f1b5..ec1236a5d 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -27,11 +27,22 @@ describe User, "showing the name" 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 (Account suspended)' + describe 'if user has been banned' do + + before do + @user.ban_text = "Naughty user" + end + + it 'should show an "Account suspended" suffix' do + @user.name.should == 'Some Name (Account suspended)' + end + + it 'should return a string when the user has been banned, not a SafeBuffer' do + @user.name.type.should == String + end end + end describe User, " when authenticating" do -- cgit v1.2.3