##// END OF EJS Templates
Test fails when run at the beginning of the day....
Jean-Philippe Lang -
r10898:d2785d680d0d
parent child
Show More
@@ -1,151 +1,151
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 20 class ActivitiesControllerTest < ActionController::TestCase
21 21 fixtures :projects, :trackers, :issue_statuses, :issues,
22 22 :enumerations, :users, :issue_categories,
23 23 :projects_trackers,
24 24 :roles,
25 25 :member_roles,
26 26 :members,
27 27 :groups_users,
28 28 :enabled_modules,
29 29 :workflows,
30 30 :journals, :journal_details
31 31
32 32
33 33 def test_project_index
34 34 get :index, :id => 1, :with_subprojects => 0
35 35 assert_response :success
36 36 assert_template 'index'
37 37 assert_not_nil assigns(:events_by_day)
38 38
39 39 assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
40 40 assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
41 41 end
42 42
43 43 def test_project_index_with_invalid_project_id_should_respond_404
44 44 get :index, :id => 299
45 45 assert_response 404
46 46 end
47 47
48 48 def test_previous_project_index
49 get :index, :id => 1, :from => 3.days.ago.to_date
49 get :index, :id => 1, :from => 2.days.ago.to_date
50 50 assert_response :success
51 51 assert_template 'index'
52 52 assert_not_nil assigns(:events_by_day)
53 53
54 54 assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
55 55 assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
56 56 end
57 57
58 58 def test_global_index
59 59 @request.session[:user_id] = 1
60 60 get :index
61 61 assert_response :success
62 62 assert_template 'index'
63 63 assert_not_nil assigns(:events_by_day)
64 64
65 65 i5 = Issue.find(5)
66 66 d5 = User.find(1).time_to_date(i5.created_on)
67 67
68 68 assert_select 'h3', :text => /#{d5.day}/
69 69 assert_select 'dl dt.issue a', :text => /Subproject issue/
70 70 end
71 71
72 72 def test_user_index
73 73 @request.session[:user_id] = 1
74 74 get :index, :user_id => 2
75 75 assert_response :success
76 76 assert_template 'index'
77 77 assert_not_nil assigns(:events_by_day)
78 78
79 79 assert_select 'h2 a[href=/users/2]', :text => 'John Smith'
80 80
81 81 i1 = Issue.find(1)
82 82 d1 = User.find(1).time_to_date(i1.created_on)
83 83
84 84 assert_select 'h3', :text => /#{d1.day}/
85 85 assert_select 'dl dt.issue a', :text => /Can&#x27;t print recipes/
86 86 end
87 87
88 88 def test_user_index_with_invalid_user_id_should_respond_404
89 89 get :index, :user_id => 299
90 90 assert_response 404
91 91 end
92 92
93 93 def test_index_atom_feed
94 94 get :index, :format => 'atom', :with_subprojects => 0
95 95 assert_response :success
96 96 assert_template 'common/feed'
97 97
98 98 assert_select 'feed' do
99 99 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
100 100 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
101 101 assert_select 'entry' do
102 102 assert_select 'link[href=?]', 'http://test.host/issues/11'
103 103 end
104 104 end
105 105 end
106 106
107 107 def test_index_atom_feed_with_explicit_selection
108 108 get :index, :format => 'atom', :with_subprojects => 0,
109 109 :show_changesets => 1,
110 110 :show_documents => 1,
111 111 :show_files => 1,
112 112 :show_issues => 1,
113 113 :show_messages => 1,
114 114 :show_news => 1,
115 115 :show_time_entries => 1,
116 116 :show_wiki_edits => 1
117 117
118 118 assert_response :success
119 119 assert_template 'common/feed'
120 120
121 121 assert_select 'feed' do
122 122 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
123 123 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'
124 124 assert_select 'entry' do
125 125 assert_select 'link[href=?]', 'http://test.host/issues/11'
126 126 end
127 127 end
128 128 end
129 129
130 130 def test_index_atom_feed_with_one_item_type
131 131 get :index, :format => 'atom', :show_issues => '1'
132 132 assert_response :success
133 133 assert_template 'common/feed'
134 134
135 135 assert_select 'title', :text => /Issues/
136 136 end
137 137
138 138 def test_index_should_show_private_notes_with_permission_only
139 139 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
140 140 @request.session[:user_id] = 2
141 141
142 142 get :index
143 143 assert_response :success
144 144 assert_include journal, assigns(:events_by_day).values.flatten
145 145
146 146 Role.find(1).remove_permission! :view_private_notes
147 147 get :index
148 148 assert_response :success
149 149 assert_not_include journal, assigns(:events_by_day).values.flatten
150 150 end
151 151 end
General Comments 0
You need to be logged in to leave comments. Login now