Commit 6446d98e894815b0483aa0988706ad73e617901e

Authored by Antonio Terceiro
1 parent 937b283e

ActionItem956: displaying profiles to admins

app/models/profile.rb
@@ -470,7 +470,7 @@ class Profile < ActiveRecord::Base @@ -470,7 +470,7 @@ class Profile < ActiveRecord::Base
470 false 470 false
471 else 471 else
472 # other possibilities would come here 472 # other possibilities would come here
473 - (user == self) || (user.memberships.include?(self)) 473 + (user == self) || (user.is_admin?(self.environment)) || (user.memberships.include?(self))
474 end 474 end
475 end 475 end
476 end 476 end
test/unit/profile_test.rb
@@ -525,6 +525,13 @@ class ProfileTest < Test::Unit::TestCase @@ -525,6 +525,13 @@ class ProfileTest < Test::Unit::TestCase
525 assert c.display_info_to?(p) 525 assert c.display_info_to?(p)
526 end 526 end
527 527
  528 + should 'display profile for administrators' do
  529 + p = create_user('testuser').person
  530 + p.update_attribute('public_profile', false)
  531 + admin = Person[create_admin_user(p.environment)]
  532 + assert p.display_info_to?(admin)
  533 + end
  534 +
528 should 'be able to add extra data for index' do 535 should 'be able to add extra data for index' do
529 klass = Class.new(Profile) 536 klass = Class.new(Profile)
530 klass.any_instance.expects(:random_method) 537 klass.any_instance.expects(:random_method)