24568_show_locked_users_in_timelog_report.patch

Marius BALTEANU, 2018-06-17 21:51

Download (2.74 KB)

View differences:

app/helpers/timelog_helper.rb
58 58
    sum
59 59
  end
60 60

  
61
  def format_criteria_value(criteria_options, value)
61
  def format_criteria_value(criteria_options, value, html=true)
62 62
    if value.blank?
63 63
      "[#{l(:label_none)}]"
64 64
    elsif k = criteria_options[:klass]
65 65
      obj = k.find_by_id(value.to_i)
66
      if obj.is_a?(Issue)
67
        obj.visible? ? "#{obj.tracker} ##{obj.id}: #{obj.subject}" : "##{obj.id}"
68
      else
69
        obj
70
      end
66
      format_object(obj, html)
71 67
    elsif cf = criteria_options[:custom_field]
72 68
      format_value(value, cf)
73 69
    else
......
103 99
      hours_for_value = select_hours(hours, criteria[level], value)
104 100
      next if hours_for_value.empty?
105 101
      row = [''] * level
106
      row << format_criteria_value(available_criteria[criteria[level]], value).to_s
102
      row << format_criteria_value(available_criteria[criteria[level]], value, false).to_s
107 103
      row += [''] * (criteria.length - level - 1)
108 104
      total = 0
109 105
      periods.each do |period|
test/functional/timelog_report_test.rb
71 71
    get :report, :params => {:columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criteria => ['project']}
72 72
    assert_response :success
73 73
    assert_select 'tr.total td:last', :text => '8.65'
74
    assert_select 'tr td.name a[href=?]', '/projects/ecookbook', :text => 'eCookbook'
74 75
  end
75 76

  
76 77
  def test_report_all_time
......
98 99
    assert_select 'tr.total td:last', :text => '162.90'
99 100
  end
100 101

  
102
  def test_report_should_show_locked_users
103
    @request.session[:user_id] = 1
104

  
105
    user = User.find(2)
106
    user.status = User::STATUS_LOCKED
107
    user.save
108

  
109
    get :report, :params => {:project_id => 1, :columns => 'month', :criteria => ["user", "activity"]}
110
    assert_response :success
111

  
112
    assert_select 'td.name a.user.active[href=?]', '/users/1', 1, :text => 'Redmine Admin'
113
    assert_select 'td.name a.user.locked[href=?]', '/users/2', 1, :text => 'John Smith'
114
  end
115

  
101 116
  def test_report_custom_field_criteria_with_multiple_values_on_single_value_custom_field_should_not_fail
102 117
    field = TimeEntryCustomField.create!(:name => 'multi', :field_format => 'list', :possible_values => ['value1', 'value2'])
103 118
    entry = TimeEntry.create!(:project => Project.find(1), :hours => 1, :activity_id => 10, :user => User.find(2), :spent_on => Date.today)