From 4c9f55d1e157ba65ce757b1d91c9dd7f251c215b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 25 Nov 2014 16:14:21 -0500 Subject: [PATCH] FIX: Suspended users should have links stripped from their profiles. --- app/models/user_profile.rb | 4 ++-- spec/models/user_profile_spec.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/user_profile.rb b/app/models/user_profile.rb index 3059d2a289a..06be18d41c1 100644 --- a/app/models/user_profile.rb +++ b/app/models/user_profile.rb @@ -12,12 +12,12 @@ class UserProfile < ActiveRecord::Base def bio_excerpt excerpt = PrettyText.excerpt(bio_cooked, 350) - return excerpt if excerpt.blank? || user.has_trust_level?(TrustLevel[1]) + return excerpt if excerpt.blank? || (user.has_trust_level?(TrustLevel[1]) && !user.suspended?) PrettyText.strip_links(excerpt) end def bio_processed - return bio_cooked if bio_cooked.blank? || user.has_trust_level?(TrustLevel[1]) + return bio_cooked if bio_cooked.blank? || (user.has_trust_level?(TrustLevel[1]) && !user.suspended?) PrettyText.strip_links(bio_cooked) end diff --git a/spec/models/user_profile_spec.rb b/spec/models/user_profile_spec.rb index ad18eb8617e..a30403fc233 100644 --- a/spec/models/user_profile_spec.rb +++ b/spec/models/user_profile_spec.rb @@ -103,6 +103,14 @@ describe UserProfile do expect(user_profile.bio_processed).to eq("

I love http://discourse.org

") end + it 'removes the link if the user is suspended' do + user.suspended_till = 1.month.from_now + puts user.suspended?.inspect + user_profile.send(:cook) + expect(user_profile.bio_excerpt).to match_html("I love http://discourse.org") + expect(user_profile.bio_processed).to eq("

I love http://discourse.org

") + end + context 'tl3_links_no_follow is false' do before { SiteSetting.stubs(:tl3_links_no_follow).returns(false) }