Browse Source

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
tags/2.4.0
Jean-Philippe Lang 10 years ago
parent
commit
dc5e5eca6b

+ 4
- 0
app/models/custom_field.rb View File

@@ -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?

+ 1
- 1
app/models/issue_custom_field.rb View File

@@ -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

+ 11
- 0
test/functional/timelog_controller_test.rb View File

@@ -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

Loading…
Cancel
Save