comparison test/unit/activity_test.rb @ 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 e248c7af89ec
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 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.
17 17
18 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 class ActivityTest < ActiveSupport::TestCase 20 class ActivityTest < ActiveSupport::TestCase
21 fixtures :projects, :versions, :attachments, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, 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 22 :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, :time_entries,
23 :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
23 24
24 def setup 25 def setup
25 @project = Project.find(1) 26 @project = Project.find(1)
26 end 27 end
27 28
85 assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1)) 86 assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1))
86 assert_equal [Attachment], events.collect(&:class).uniq 87 assert_equal [Attachment], events.collect(&:class).uniq
87 assert_equal %w(Project Version), events.collect(&:container_type).uniq.sort 88 assert_equal %w(Project Version), events.collect(&:container_type).uniq.sort
88 end 89 end
89 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
90 private 124 private
91 125
92 def find_events(user, options={}) 126 def find_events(user, options={})
93 Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1) 127 Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1)
94 end 128 end