Commit fb79fda05e5f27bc1ce776084c41337a059fc384
1 parent
4b392f22
Exists in
master
and in
22 other branches
profile: include public named_scope
Showing
2 changed files
with
13 additions
and
0 deletions
Show diff stats
app/models/profile.rb
| ... | ... | @@ -112,6 +112,7 @@ class Profile < ActiveRecord::Base |
| 112 | 112 | end |
| 113 | 113 | |
| 114 | 114 | named_scope :visible, :conditions => { :visible => true } |
| 115 | + named_scope :public, :conditions => { :visible => true, :public_profile => true } | |
| 115 | 116 | # Subclasses must override these methods |
| 116 | 117 | named_scope :more_popular |
| 117 | 118 | named_scope :more_active | ... | ... |
test/unit/profile_test.rb
| ... | ... | @@ -1833,4 +1833,16 @@ class ProfileTest < ActiveSupport::TestCase |
| 1833 | 1833 | assert_equal f, p.fields_privacy |
| 1834 | 1834 | end |
| 1835 | 1835 | |
| 1836 | + should 'list only public profiles' do | |
| 1837 | + p1 = fast_create(Profile) | |
| 1838 | + p2 = fast_create(Profile, :visible => false) | |
| 1839 | + p3 = fast_create(Profile, :public_profile => false) | |
| 1840 | + p4 = fast_create(Profile, :visible => false, :public_profile => false) | |
| 1841 | + | |
| 1842 | + assert_includes Profile.public, p1 | |
| 1843 | + assert_not_includes Profile.public, p2 | |
| 1844 | + assert_not_includes Profile.public, p3 | |
| 1845 | + assert_not_includes Profile.public, p4 | |
| 1846 | + end | |
| 1847 | + | |
| 1836 | 1848 | end | ... | ... |