Mercurial > hg > soundsoftware-site
comparison test/unit/.svn/text-base/activity_test.rb.svn-base @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 8661b858af72 |
children |
comparison
equal
deleted
inserted
replaced
245:051f544170fe | 441:cbce1fd3b1b7 |
---|---|
1 # redMine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2008 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 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 | 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. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
22 :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages | 22 :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages |
23 | 23 |
24 def setup | 24 def setup |
25 @project = Project.find(1) | 25 @project = Project.find(1) |
26 end | 26 end |
27 | 27 |
28 def test_activity_without_subprojects | 28 def test_activity_without_subprojects |
29 events = find_events(User.anonymous, :project => @project) | 29 events = find_events(User.anonymous, :project => @project) |
30 assert_not_nil events | 30 assert_not_nil events |
31 | 31 |
32 assert events.include?(Issue.find(1)) | 32 assert events.include?(Issue.find(1)) |
33 assert !events.include?(Issue.find(4)) | 33 assert !events.include?(Issue.find(4)) |
34 # subproject issue | 34 # subproject issue |
35 assert !events.include?(Issue.find(5)) | 35 assert !events.include?(Issue.find(5)) |
36 end | 36 end |
37 | 37 |
38 def test_activity_with_subprojects | 38 def test_activity_with_subprojects |
39 events = find_events(User.anonymous, :project => @project, :with_subprojects => 1) | 39 events = find_events(User.anonymous, :project => @project, :with_subprojects => 1) |
40 assert_not_nil events | 40 assert_not_nil events |
41 | 41 |
42 assert events.include?(Issue.find(1)) | 42 assert events.include?(Issue.find(1)) |
43 # subproject issue | 43 # subproject issue |
44 assert events.include?(Issue.find(5)) | 44 assert events.include?(Issue.find(5)) |
45 end | 45 end |
46 | 46 |
47 def test_global_activity_anonymous | 47 def test_global_activity_anonymous |
48 events = find_events(User.anonymous) | 48 events = find_events(User.anonymous) |
49 assert_not_nil events | 49 assert_not_nil events |
50 | 50 |
51 assert events.include?(Issue.find(1)) | 51 assert events.include?(Issue.find(1)) |
52 assert events.include?(Message.find(5)) | 52 assert events.include?(Message.find(5)) |
53 # Issue of a private project | 53 # Issue of a private project |
54 assert !events.include?(Issue.find(4)) | 54 assert !events.include?(Issue.find(4)) |
55 # Private issue and comment | |
56 assert !events.include?(Issue.find(14)) | |
57 assert !events.include?(Journal.find(5)) | |
55 end | 58 end |
56 | 59 |
57 def test_global_activity_logged_user | 60 def test_global_activity_logged_user |
58 events = find_events(User.find(2)) # manager | 61 events = find_events(User.find(2)) # manager |
59 assert_not_nil events | 62 assert_not_nil events |
60 | 63 |
61 assert events.include?(Issue.find(1)) | 64 assert events.include?(Issue.find(1)) |
62 # Issue of a private project the user belongs to | 65 # Issue of a private project the user belongs to |
63 assert events.include?(Issue.find(4)) | 66 assert events.include?(Issue.find(4)) |
64 end | 67 end |
65 | 68 |
66 def test_user_activity | 69 def test_user_activity |
67 user = User.find(2) | 70 user = User.find(2) |
68 events = Redmine::Activity::Fetcher.new(User.anonymous, :author => user).events(nil, nil, :limit => 10) | 71 events = Redmine::Activity::Fetcher.new(User.anonymous, :author => user).events(nil, nil, :limit => 10) |
69 | 72 |
70 assert(events.size > 0) | 73 assert(events.size > 0) |
71 assert(events.size <= 10) | 74 assert(events.size <= 10) |
72 assert_nil(events.detect {|e| e.event_author != user}) | 75 assert_nil(events.detect {|e| e.event_author != user}) |
73 end | 76 end |
74 | 77 |
75 def test_files_activity | 78 def test_files_activity |
76 f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1)) | 79 f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1)) |
77 f.scope = ['files'] | 80 f.scope = ['files'] |
78 events = f.events | 81 events = f.events |
79 | 82 |
80 assert_kind_of Array, events | 83 assert_kind_of Array, events |
81 assert events.include?(Attachment.find_by_container_type_and_container_id('Project', 1)) | 84 assert events.include?(Attachment.find_by_container_type_and_container_id('Project', 1)) |
82 assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1)) | 85 assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1)) |
83 assert_equal [Attachment], events.collect(&:class).uniq | 86 assert_equal [Attachment], events.collect(&:class).uniq |
84 assert_equal %w(Project Version), events.collect(&:container_type).uniq.sort | 87 assert_equal %w(Project Version), events.collect(&:container_type).uniq.sort |
85 end | 88 end |
86 | 89 |
87 private | 90 private |
88 | 91 |
89 def find_events(user, options={}) | 92 def find_events(user, options={}) |
90 Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1) | 93 Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1) |
91 end | 94 end |
92 end | 95 end |