@@ -0,0 +1,50 | |||
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2015 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU General Public License | |
|
15 | # along with this program; if not, write to the Free Software | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | require File.expand_path('../../../test_helper', __FILE__) | |
|
19 | ||
|
20 | class MyHelperTest < ActionView::TestCase | |
|
21 | include Redmine::I18n | |
|
22 | include ERB::Util | |
|
23 | include MyHelper | |
|
24 | ||
|
25 | ||
|
26 | fixtures :projects, :trackers, :issue_statuses, :issues, | |
|
27 | :enumerations, :users, :issue_categories, | |
|
28 | :projects_trackers, | |
|
29 | :roles, | |
|
30 | :member_roles, | |
|
31 | :members, | |
|
32 | :enabled_modules, | |
|
33 | :versions | |
|
34 | ||
|
35 | def test_timelog_items_should_include_time_entries_without_issue | |
|
36 | User.current = User.find(2) | |
|
37 | entry = TimeEntry.generate!(:spent_on => Date.today, :user_id => 2, :project_id => 1) | |
|
38 | assert_nil entry.issue | |
|
39 | ||
|
40 | assert_include entry, timelog_items | |
|
41 | end | |
|
42 | ||
|
43 | def test_timelog_items_should_include_time_entries_with_issue | |
|
44 | User.current = User.find(2) | |
|
45 | entry = TimeEntry.generate!(:spent_on => Date.today, :user_id => 2, :project_id => 1, :issue_id => 1) | |
|
46 | assert_not_nil entry.issue | |
|
47 | ||
|
48 | assert_include entry, timelog_items | |
|
49 | end | |
|
50 | end |
@@ -68,7 +68,9 module MyHelper | |||
|
68 | 68 | def timelog_items |
|
69 | 69 | TimeEntry. |
|
70 | 70 | where("#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", User.current.id, Date.today - 6, Date.today). |
|
71 |
joins(:activity, :project |
|
|
71 | joins(:activity, :project). | |
|
72 | references(:issue => [:tracker, :status]). | |
|
73 | includes(:issue => [:tracker, :status]). | |
|
72 | 74 | order("#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC"). |
|
73 | 75 | to_a |
|
74 | 76 | end |
General Comments 0
You need to be logged in to leave comments.
Login now