Project

General

Profile

Feature #30464 » estimated-hours-on-overview-page-v2.diff

Added a test - Go MAEDA, 2019-01-22 03:25

View differences:

app/controllers/projects_controller.rb (working copy)
158 158
    if User.current.allowed_to_view_all_time_entries?(@project)
159 159
      @total_hours = TimeEntry.visible.where(cond).sum(:hours).to_f
160
      @total_estimated_hours = Issue.visible.where(cond).sum(:estimated_hours).to_f
160 161
    end
161 162
    @key = User.current.rss_key
app/views/projects/show.html.erb (working copy)
83 83
  <% if User.current.allowed_to?(:view_time_entries, @project) %>
84 84
  <div class="spent_time box">
85
    <h3 class="icon icon-time"><%= l(:label_spent_time) %></h3>
85
    <h3 class="icon icon-time"><%= l(:label_time_tracking) %></h3>
86
    <ul>
86 87
    <% if @total_hours.present? %>
87
      <p><%= l_hours(@total_hours) %></p>
88
        <li><%= l(:label_spent_time) %>: <%= l_hours(@total_hours) %>
88 89
    <% end %>
90
      <% if @total_estimated_hours.present? %>
91
        <li><%= l(:field_estimated_hours) %>: <%= l_hours(@total_estimated_hours) %>
92
      <% end %>
93
    </ul>
89 94
    <p>
90 95
    <% if User.current.allowed_to?(:log_time, @project) %>
91 96
      <%= link_to l(:button_log_time), new_project_time_entry_path(@project) %> |
test/fixtures/issues.yml (working copy)
15 15
  status_id: 1
16 16
  start_date: <%= 1.day.ago.to_date.to_s(:db) %>
17 17
  due_date: <%= 10.day.from_now.to_date.to_s(:db) %>
18
  estimated_hours: 200.0
18 19
  root_id: 1
19 20
  lft: 1
20 21
  rgt: 2
......
36 37
  start_date: <%= 2.day.ago.to_date.to_s(:db) %>
37 38
  due_date:
38 39
  root_id: 2
40
  estimated_hours: 0.5
39 41
  lft: 1
40 42
  rgt: 2
41 43
  lock_version: 3
......
56 58
  status_id: 1
57 59
  start_date: <%= 15.day.ago.to_date.to_s(:db) %>
58 60
  due_date: <%= 5.day.ago.to_date.to_s(:db) %>
61
  estimated_hours: 1.0
59 62
  root_id: 3
60 63
  lft: 1
61 64
  rgt: 2
......
90 93
  assigned_to_id:
91 94
  author_id: 2
92 95
  status_id: 1
96
  estimated_hours: 2.0
93 97
  root_id: 5
94 98
  lft: 1
95 99
  rgt: 2
test/functional/projects_controller_test.rb (working copy)
575 575
    assert_select 'table.issue-report td.total a', :text => %r{\A[1-9]\d*\z}
576 576
  end
577
  def test_show_should_spent_and_estimated_time
578
    @request.session[:user_id] = 1
579
    get :show, :params => {
580
        :id => 'ecookbook'
581
      }
582

  
583
    assert_select 'div.spent_time.box>ul' do
584
      assert_select 'li:nth-child(1)', :text => 'Spent time: 162.90 hours'
585
      assert_select 'li:nth-child(2)', :text => 'Estimated time: 203.50 hours'
586
    end
587
  end
588

  
577 589
  def test_settings
578 590
    @request.session[:user_id] = 2 # manager
579 591
    get :settings, :params => {
(3-3/5)