Commit bdff2d88be32c7a010d0e97dd790593e99e470ae
Exists in
master
and in
29 other branches
Merge commit 'refs/merge-requests/364' of git://gitorious.org/noosfero/noosfero …
…into merge-requests/364 Conflicts: test/unit/person_test.rb
Showing
2 changed files
with
14 additions
and
15 deletions
Show diff stats
app/models/person.rb
| ... | ... | @@ -471,8 +471,9 @@ class Person < Profile |
| 471 | 471 | Scrap.find_by_sql("SELECT id, updated_at, '#{Scrap.to_s}' AS klass FROM #{Scrap.table_name} WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} WHERE action_tracker.user_id = #{self.id} and action_tracker.verb != 'leave_scrap_to_self' and action_tracker.verb != 'add_member_in_community' ORDER BY updated_at DESC") |
| 472 | 472 | end |
| 473 | 473 | |
| 474 | + # by default, all fields are private | |
| 474 | 475 | def public_fields |
| 475 | - self.fields_privacy.nil? ? self.active_fields : self.fields_privacy.reject{ |k, v| v != 'public' }.keys.map(&:to_s) | |
| 476 | + self.fields_privacy.nil? ? [] : self.fields_privacy.reject{ |k, v| v != 'public' }.keys.map(&:to_s) | |
| 476 | 477 | end |
| 477 | 478 | |
| 478 | 479 | protected | ... | ... |
test/unit/person_test.rb
| ... | ... | @@ -55,7 +55,7 @@ class PersonTest < ActiveSupport::TestCase |
| 55 | 55 | |
| 56 | 56 | p1 = u.person |
| 57 | 57 | assert_equal u, p1.user |
| 58 | - | |
| 58 | + | |
| 59 | 59 | p2 = Person.new(:environment => Environment.default) |
| 60 | 60 | p2.user = u |
| 61 | 61 | assert !p2.valid? |
| ... | ... | @@ -202,7 +202,7 @@ class PersonTest < ActiveSupport::TestCase |
| 202 | 202 | should 'have friends' do |
| 203 | 203 | p1 = create_user('testuser1').person |
| 204 | 204 | p2 = create_user('testuser2').person |
| 205 | - | |
| 205 | + | |
| 206 | 206 | p1.add_friend(p2) |
| 207 | 207 | |
| 208 | 208 | p1.friends.reload |
| ... | ... | @@ -237,7 +237,7 @@ class PersonTest < ActiveSupport::TestCase |
| 237 | 237 | p2 = create_user('testuser2').person |
| 238 | 238 | p3 = create_user('testuser3').person |
| 239 | 239 | p4 = create_user('testuser4').person |
| 240 | - | |
| 240 | + | |
| 241 | 241 | p1.add_friend(p2, 'group1') |
| 242 | 242 | p1.add_friend(p3, 'group2') |
| 243 | 243 | p1.add_friend(p4, 'group1') |
| ... | ... | @@ -248,7 +248,7 @@ class PersonTest < ActiveSupport::TestCase |
| 248 | 248 | should 'not suggest duplicated friend groups' do |
| 249 | 249 | p1 = create_user('testuser1').person |
| 250 | 250 | p2 = create_user('testuser2').person |
| 251 | - | |
| 251 | + | |
| 252 | 252 | p1.add_friend(p2, 'friends') |
| 253 | 253 | |
| 254 | 254 | assert_equal p1.suggested_friend_groups, p1.suggested_friend_groups.uniq |
| ... | ... | @@ -307,7 +307,7 @@ class PersonTest < ActiveSupport::TestCase |
| 307 | 307 | assert_equal 'my contact', person.contact_information |
| 308 | 308 | end |
| 309 | 309 | |
| 310 | - should 'provide desired info fields' do | |
| 310 | + should 'provide desired info fields' do | |
| 311 | 311 | p = Person.new(:environment => Environment.default) |
| 312 | 312 | assert p.respond_to?(:photo) |
| 313 | 313 | assert p.respond_to?(:address) |
| ... | ... | @@ -472,7 +472,7 @@ class PersonTest < ActiveSupport::TestCase |
| 472 | 472 | should 'require custom_area_of_study if area_of_study is others' do |
| 473 | 473 | e = Environment.default |
| 474 | 474 | e.expects(:required_person_fields).returns(['area_of_study', 'custom_area_of_study']).at_least_once |
| 475 | - | |
| 475 | + | |
| 476 | 476 | person = Person.new(:environment => e, :area_of_study => 'Others') |
| 477 | 477 | assert !person.valid? |
| 478 | 478 | assert person.errors.invalid?(:custom_area_of_study) |
| ... | ... | @@ -507,7 +507,7 @@ class PersonTest < ActiveSupport::TestCase |
| 507 | 507 | should 'not require custom_formation if formation is not others' do |
| 508 | 508 | e = Environment.default |
| 509 | 509 | e.expects(:required_person_fields).returns(['formation']).at_least_once |
| 510 | - | |
| 510 | + | |
| 511 | 511 | person = Person.new(:environment => e, :formation => 'Agrometeorology') |
| 512 | 512 | assert !person.valid? |
| 513 | 513 | assert ! person.errors.invalid?(:custom_formation) |
| ... | ... | @@ -854,7 +854,7 @@ class PersonTest < ActiveSupport::TestCase |
| 854 | 854 | assert !p1.is_a_friend?(p3) |
| 855 | 855 | p1.add_friend(p4) |
| 856 | 856 | assert p1.is_a_friend?(p4) |
| 857 | - | |
| 857 | + | |
| 858 | 858 | action_tracker = fast_create(ActionTracker::Record) |
| 859 | 859 | |
| 860 | 860 | assert_difference(Delayed::Job, :count, 1) do |
| ... | ... | @@ -873,7 +873,7 @@ class PersonTest < ActiveSupport::TestCase |
| 873 | 873 | assert !p1.is_a_friend?(p3) |
| 874 | 874 | p1.add_friend(p4) |
| 875 | 875 | assert p1.is_a_friend?(p4) |
| 876 | - | |
| 876 | + | |
| 877 | 877 | action_tracker = fast_create(ActionTracker::Record, :user_id => p1.id) |
| 878 | 878 | |
| 879 | 879 | Delayed::Job.delete_all |
| ... | ... | @@ -926,7 +926,7 @@ class PersonTest < ActiveSupport::TestCase |
| 926 | 926 | community.add_member(p4) |
| 927 | 927 | assert p4.is_member_of?(community) |
| 928 | 928 | assert !p2.is_member_of?(community) |
| 929 | - | |
| 929 | + | |
| 930 | 930 | action_tracker = fast_create(ActionTracker::Record) |
| 931 | 931 | article = mock() |
| 932 | 932 | action_tracker.stubs(:target).returns(article) |
| ... | ... | @@ -1277,12 +1277,10 @@ class PersonTest < ActiveSupport::TestCase |
| 1277 | 1277 | assert person.has_permission?('bli', Profile.new) |
| 1278 | 1278 | end |
| 1279 | 1279 | |
| 1280 | - should 'active fields are public if fields privacy is nil' do | |
| 1280 | + should 'active fields are private if fields privacy is nil' do | |
| 1281 | 1281 | p = fast_create(Person) |
| 1282 | 1282 | p.expects(:fields_privacy).returns(nil) |
| 1283 | - f = %w(sex birth_date) | |
| 1284 | - p.expects(:active_fields).returns(f) | |
| 1285 | - assert_equal f, p.public_fields | |
| 1283 | + assert_equal [], p.public_fields | |
| 1286 | 1284 | end |
| 1287 | 1285 | |
| 1288 | 1286 | should 'return public fields' do | ... | ... |