end
# Find the name of an associated record stored in the field attribute
+ # For project, return the associated record only if is visible for the current User
def find_name_by_reflection(field, id)
return nil if id.blank?
name = nil
if association
record = association.klass.find_by_id(key.last)
- if record
+ if (record && !record.is_a?(Project)) || (record.is_a?(Project) && record.visible?)
name = record.name.force_encoding('UTF-8')
end
end
end
test 'show_detail should show old and new values with a project attribute' do
+ User.current = User.find(2)
detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id',
:old_value => 1, :value => 2)
assert_match 'eCookbook', show_detail(detail, true)
assert_match 'OnlineStore', show_detail(detail, true)
end
+ test 'show_detail with a project attribute should show project ID if project is not visible' do
+ detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id',
+ :old_value => 1, :value => 2)
+ assert_match 'eCookbook', show_detail(detail, true)
+ assert_match '2', show_detail(detail, true)
+ end
+
test 'show_detail should show old and new values with a issue status attribute' do
detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id',
:old_value => 1, :value => 2)