diff --git a/app/models/profile.rb b/app/models/profile.rb index 6ceabcd..0c04b5c 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -112,6 +112,7 @@ class Profile < ActiveRecord::Base end named_scope :visible, :conditions => { :visible => true } + named_scope :public, :conditions => { :visible => true, :public_profile => true } # Subclasses must override these methods named_scope :more_popular named_scope :more_active diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index 72215f8..ac9b3b4 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -1833,4 +1833,16 @@ class ProfileTest < ActiveSupport::TestCase assert_equal f, p.fields_privacy end + should 'list only public profiles' do + p1 = fast_create(Profile) + p2 = fast_create(Profile, :visible => false) + p3 = fast_create(Profile, :public_profile => false) + p4 = fast_create(Profile, :visible => false, :public_profile => false) + + assert_includes Profile.public, p1 + assert_not_includes Profile.public, p2 + assert_not_includes Profile.public, p3 + assert_not_includes Profile.public, p4 + end + end -- libgit2 0.21.2