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