From dc5e5eca6b7cb124da1e47036f8a688bb4a7688c Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 24 Jul 2013 18:18:08 +0000 Subject: [PATCH] Fixed that displaying time entries with custom field column raises an error (#5037). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12041 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/custom_field.rb | 4 ++++ app/models/issue_custom_field.rb | 2 +- test/functional/timelog_controller_test.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index c2b717d0e..f469bc534 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -76,6 +76,10 @@ class CustomField < ActiveRecord::Base CUSTOM_FIELDS_NAMES = CUSTOM_FIELDS_TABS.collect{|v| v[:name]} + def visible_by?(project, user=User.current) + visible? || user.admin? + end + def field_format=(arg) # cannot change format of a saved custom field super if new_record? diff --git a/app/models/issue_custom_field.rb b/app/models/issue_custom_field.rb index 9ddedc882..e811ccaae 100644 --- a/app/models/issue_custom_field.rb +++ b/app/models/issue_custom_field.rb @@ -25,7 +25,7 @@ class IssueCustomField < CustomField end def visible_by?(project, user=User.current) - visible? || user.admin? || (roles & user.roles_for_project(project)).present? + super || (roles & user.roles_for_project(project)).present? end def validate_custom_field diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 2cc9bf778..5735260ca 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -548,6 +548,17 @@ class TimelogControllerTest < ActionController::TestCase assert_select 'td.issue_cf_2', :text => 'filter_on_issue_custom_field' end + def test_index_with_time_entry_custom_field_column + field = TimeEntryCustomField.generate!(:field_format => 'string') + entry = TimeEntry.generate!(:hours => 2.5, :custom_field_values => {field.id => 'CF Value'}) + field_name = "cf_#{field.id}" + + get :index, :c => ["hours", field_name] + assert_response :success + assert_include field_name.to_sym, assigns(:query).column_names + assert_select "td.#{field_name}", :text => 'CF Value' + end + def test_index_atom_feed get :index, :project_id => 1, :format => 'atom' assert_response :success -- 2.39.5