FIX: Suspended users should have links stripped from their profiles.

This commit is contained in:
Robin Ward 2014-11-25 16:14:21 -05:00
parent 183c93904d
commit 4c9f55d1e1
2 changed files with 10 additions and 2 deletions

View File

@ -12,12 +12,12 @@ class UserProfile < ActiveRecord::Base
def bio_excerpt def bio_excerpt
excerpt = PrettyText.excerpt(bio_cooked, 350) 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) PrettyText.strip_links(excerpt)
end end
def bio_processed 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) PrettyText.strip_links(bio_cooked)
end end

View File

@ -103,6 +103,14 @@ describe UserProfile do
expect(user_profile.bio_processed).to eq("<p>I love http://discourse.org</p>") expect(user_profile.bio_processed).to eq("<p>I love http://discourse.org</p>")
end 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("<p>I love http://discourse.org</p>")
end
context 'tl3_links_no_follow is false' do context 'tl3_links_no_follow is false' do
before { SiteSetting.stubs(:tl3_links_no_follow).returns(false) } before { SiteSetting.stubs(:tl3_links_no_follow).returns(false) }