@@ -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 |
@@ -1,75 +1,77 | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | 2 | # |
|
3 | 3 | # Redmine - project management software |
|
4 | 4 | # Copyright (C) 2006-2015 Jean-Philippe Lang |
|
5 | 5 | # |
|
6 | 6 | # This program is free software; you can redistribute it and/or |
|
7 | 7 | # modify it under the terms of the GNU General Public License |
|
8 | 8 | # as published by the Free Software Foundation; either version 2 |
|
9 | 9 | # of the License, or (at your option) any later version. |
|
10 | 10 | # |
|
11 | 11 | # This program is distributed in the hope that it will be useful, |
|
12 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | 14 | # GNU General Public License for more details. |
|
15 | 15 | # |
|
16 | 16 | # You should have received a copy of the GNU General Public License |
|
17 | 17 | # along with this program; if not, write to the Free Software |
|
18 | 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
19 | 19 | |
|
20 | 20 | module MyHelper |
|
21 | 21 | def calendar_items(startdt, enddt) |
|
22 | 22 | Issue.visible. |
|
23 | 23 | where(:project_id => User.current.projects.map(&:id)). |
|
24 | 24 | where("(start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)", startdt, enddt, startdt, enddt). |
|
25 | 25 | includes(:project, :tracker, :priority, :assigned_to). |
|
26 | 26 | references(:project, :tracker, :priority, :assigned_to). |
|
27 | 27 | to_a |
|
28 | 28 | end |
|
29 | 29 | |
|
30 | 30 | def documents_items |
|
31 | 31 | Document.visible.order("#{Document.table_name}.created_on DESC").limit(10).to_a |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def issuesassignedtome_items |
|
35 | 35 | Issue.visible.open. |
|
36 | 36 | where(:assigned_to_id => ([User.current.id] + User.current.group_ids)). |
|
37 | 37 | limit(10). |
|
38 | 38 | includes(:status, :project, :tracker, :priority). |
|
39 | 39 | references(:status, :project, :tracker, :priority). |
|
40 | 40 | order("#{IssuePriority.table_name}.position DESC, #{Issue.table_name}.updated_on DESC"). |
|
41 | 41 | to_a |
|
42 | 42 | end |
|
43 | 43 | |
|
44 | 44 | def issuesreportedbyme_items |
|
45 | 45 | Issue.visible. |
|
46 | 46 | where(:author_id => User.current.id). |
|
47 | 47 | limit(10). |
|
48 | 48 | includes(:status, :project, :tracker). |
|
49 | 49 | references(:status, :project, :tracker). |
|
50 | 50 | order("#{Issue.table_name}.updated_on DESC"). |
|
51 | 51 | to_a |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | def issueswatched_items |
|
55 | 55 | Issue.visible.on_active_project.watched_by(User.current.id).recently_updated.limit(10).to_a |
|
56 | 56 | end |
|
57 | 57 | |
|
58 | 58 | def news_items |
|
59 | 59 | News.visible. |
|
60 | 60 | where(:project_id => User.current.projects.map(&:id)). |
|
61 | 61 | limit(10). |
|
62 | 62 | includes(:project, :author). |
|
63 | 63 | references(:project, :author). |
|
64 | 64 | order("#{News.table_name}.created_on DESC"). |
|
65 | 65 | to_a |
|
66 | 66 | end |
|
67 | 67 | |
|
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 |
|
75 | 77 | end |
General Comments 0
You need to be logged in to leave comments.
Login now