Mercurial > hg > soundsoftware-site
comparison .svn/pristine/78/78376d3215166c5e884949655b3cf6e5caa6e30e.svn-base @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2013 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 ActivityTest < ActiveSupport::TestCase | |
21 fixtures :projects, :versions, :attachments, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, | |
22 :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, :time_entries, | |
23 :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions | |
24 | |
25 def setup | |
26 @project = Project.find(1) | |
27 end | |
28 | |
29 def test_activity_without_subprojects | |
30 events = find_events(User.anonymous, :project => @project) | |
31 assert_not_nil events | |
32 | |
33 assert events.include?(Issue.find(1)) | |
34 assert !events.include?(Issue.find(4)) | |
35 # subproject issue | |
36 assert !events.include?(Issue.find(5)) | |
37 end | |
38 | |
39 def test_activity_with_subprojects | |
40 events = find_events(User.anonymous, :project => @project, :with_subprojects => 1) | |
41 assert_not_nil events | |
42 | |
43 assert events.include?(Issue.find(1)) | |
44 # subproject issue | |
45 assert events.include?(Issue.find(5)) | |
46 end | |
47 | |
48 def test_global_activity_anonymous | |
49 events = find_events(User.anonymous) | |
50 assert_not_nil events | |
51 | |
52 assert events.include?(Issue.find(1)) | |
53 assert events.include?(Message.find(5)) | |
54 # Issue of a private project | |
55 assert !events.include?(Issue.find(4)) | |
56 # Private issue and comment | |
57 assert !events.include?(Issue.find(14)) | |
58 assert !events.include?(Journal.find(5)) | |
59 end | |
60 | |
61 def test_global_activity_logged_user | |
62 events = find_events(User.find(2)) # manager | |
63 assert_not_nil events | |
64 | |
65 assert events.include?(Issue.find(1)) | |
66 # Issue of a private project the user belongs to | |
67 assert events.include?(Issue.find(4)) | |
68 end | |
69 | |
70 def test_user_activity | |
71 user = User.find(2) | |
72 events = Redmine::Activity::Fetcher.new(User.anonymous, :author => user).events(nil, nil, :limit => 10) | |
73 | |
74 assert(events.size > 0) | |
75 assert(events.size <= 10) | |
76 assert_nil(events.detect {|e| e.event_author != user}) | |
77 end | |
78 | |
79 def test_files_activity | |
80 f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1)) | |
81 f.scope = ['files'] | |
82 events = f.events | |
83 | |
84 assert_kind_of Array, events | |
85 assert events.include?(Attachment.find_by_container_type_and_container_id('Project', 1)) | |
86 assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1)) | |
87 assert_equal [Attachment], events.collect(&:class).uniq | |
88 assert_equal %w(Project Version), events.collect(&:container_type).uniq.sort | |
89 end | |
90 | |
91 def test_event_group_for_issue | |
92 issue = Issue.find(1) | |
93 assert_equal issue, issue.event_group | |
94 end | |
95 | |
96 def test_event_group_for_journal | |
97 issue = Issue.find(1) | |
98 journal = issue.journals.first | |
99 assert_equal issue, journal.event_group | |
100 end | |
101 | |
102 def test_event_group_for_issue_time_entry | |
103 time = TimeEntry.where(:issue_id => 1).first | |
104 assert_equal time.issue, time.event_group | |
105 end | |
106 | |
107 def test_event_group_for_project_time_entry | |
108 time = TimeEntry.where(:issue_id => nil).first | |
109 assert_equal time, time.event_group | |
110 end | |
111 | |
112 def test_event_group_for_message | |
113 message = Message.find(1) | |
114 reply = message.children.first | |
115 assert_equal message, message.event_group | |
116 assert_equal message, reply.event_group | |
117 end | |
118 | |
119 def test_event_group_for_wiki_content_version | |
120 content = WikiContent::Version.find(1) | |
121 assert_equal content.page, content.event_group | |
122 end | |
123 | |
124 private | |
125 | |
126 def find_events(user, options={}) | |
127 Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1) | |
128 end | |
129 end |