##// END OF EJS Templates
Merged r11128 from trunk to 2.2-stable....
Toshi MARUYAMA -
r10911:567eb70fdb63
parent child
Show More
@@ -1,166 +1,166
1 1 require File.expand_path('../../test_helper', __FILE__)
2 2
3 3 class ActivitiesControllerTest < ActionController::TestCase
4 4 fixtures :projects, :trackers, :issue_statuses, :issues,
5 5 :enumerations, :users, :issue_categories,
6 6 :projects_trackers,
7 7 :roles,
8 8 :member_roles,
9 9 :members,
10 10 :groups_users,
11 11 :enabled_modules,
12 12 :workflows,
13 13 :journals, :journal_details
14 14
15 15
16 16 def test_project_index
17 17 get :index, :id => 1, :with_subprojects => 0
18 18 assert_response :success
19 19 assert_template 'index'
20 20 assert_not_nil assigns(:events_by_day)
21 21
22 22 assert_tag :tag => "h3",
23 23 :content => /#{2.days.ago.to_date.day}/,
24 24 :sibling => { :tag => "dl",
25 25 :child => { :tag => "dt",
26 26 :attributes => { :class => /issue-edit/ },
27 27 :child => { :tag => "a",
28 28 :content => /(#{IssueStatus.find(2).name})/,
29 29 }
30 30 }
31 31 }
32 32 end
33 33
34 34 def test_project_index_with_invalid_project_id_should_respond_404
35 35 get :index, :id => 299
36 36 assert_response 404
37 37 end
38 38
39 39 def test_previous_project_index
40 get :index, :id => 1, :from => 3.days.ago.to_date
40 get :index, :id => 1, :from => 2.days.ago.to_date
41 41 assert_response :success
42 42 assert_template 'index'
43 43 assert_not_nil assigns(:events_by_day)
44 44
45 45 assert_tag :tag => "h3",
46 46 :content => /#{3.day.ago.to_date.day}/,
47 47 :sibling => { :tag => "dl",
48 48 :child => { :tag => "dt",
49 49 :attributes => { :class => /issue/ },
50 50 :child => { :tag => "a",
51 51 :content => /Can&#x27;t print recipes/,
52 52 }
53 53 }
54 54 }
55 55 end
56 56
57 57 def test_global_index
58 58 @request.session[:user_id] = 1
59 59 get :index
60 60 assert_response :success
61 61 assert_template 'index'
62 62 assert_not_nil assigns(:events_by_day)
63 63
64 64 i5 = Issue.find(5)
65 65 d5 = User.find(1).time_to_date(i5.created_on)
66 66 assert_tag :tag => "h3",
67 67 :content => /#{d5.day}/,
68 68 :sibling => { :tag => "dl",
69 69 :child => { :tag => "dt",
70 70 :attributes => { :class => /issue/ },
71 71 :child => { :tag => "a",
72 72 :content => /Subproject issue/,
73 73 }
74 74 }
75 75 }
76 76 end
77 77
78 78 def test_user_index
79 79 @request.session[:user_id] = 1
80 80 get :index, :user_id => 2
81 81 assert_response :success
82 82 assert_template 'index'
83 83 assert_not_nil assigns(:events_by_day)
84 84
85 85 assert_select 'h2 a[href=/users/2]', :text => 'John Smith'
86 86
87 87 i1 = Issue.find(1)
88 88 d1 = User.find(1).time_to_date(i1.created_on)
89 89
90 90 assert_tag :tag => "h3",
91 91 :content => /#{d1.day}/,
92 92 :sibling => { :tag => "dl",
93 93 :child => { :tag => "dt",
94 94 :attributes => { :class => /issue/ },
95 95 :child => { :tag => "a",
96 96 :content => /Can&#x27;t print recipes/,
97 97 }
98 98 }
99 99 }
100 100 end
101 101
102 102 def test_user_index_with_invalid_user_id_should_respond_404
103 103 get :index, :user_id => 299
104 104 assert_response 404
105 105 end
106 106
107 107 def test_index_atom_feed
108 108 get :index, :format => 'atom', :with_subprojects => 0
109 109 assert_response :success
110 110 assert_template 'common/feed'
111 111
112 112 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
113 113 :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'}
114 114 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
115 115 :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'}
116 116
117 117 assert_tag :tag => 'entry', :child => {
118 118 :tag => 'link',
119 119 :attributes => {:href => 'http://test.host/issues/11'}}
120 120 end
121 121
122 122 def test_index_atom_feed_with_explicit_selection
123 123 get :index, :format => 'atom', :with_subprojects => 0,
124 124 :show_changesets => 1,
125 125 :show_documents => 1,
126 126 :show_files => 1,
127 127 :show_issues => 1,
128 128 :show_messages => 1,
129 129 :show_news => 1,
130 130 :show_time_entries => 1,
131 131 :show_wiki_edits => 1
132 132
133 133 assert_response :success
134 134 assert_template 'common/feed'
135 135
136 136 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
137 137 :attributes => {: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'}
138 138 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
139 139 :attributes => {: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'}
140 140
141 141 assert_tag :tag => 'entry', :child => {
142 142 :tag => 'link',
143 143 :attributes => {:href => 'http://test.host/issues/11'}}
144 144 end
145 145
146 146 def test_index_atom_feed_with_one_item_type
147 147 get :index, :format => 'atom', :show_issues => '1'
148 148 assert_response :success
149 149 assert_template 'common/feed'
150 150 assert_tag :tag => 'title', :content => /Issues/
151 151 end
152 152
153 153 def test_index_should_show_private_notes_with_permission_only
154 154 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
155 155 @request.session[:user_id] = 2
156 156
157 157 get :index
158 158 assert_response :success
159 159 assert_include journal, assigns(:events_by_day).values.flatten
160 160
161 161 Role.find(1).remove_permission! :view_private_notes
162 162 get :index
163 163 assert_response :success
164 164 assert_not_include journal, assigns(:events_by_day).values.flatten
165 165 end
166 166 end
General Comments 0
You need to be logged in to leave comments. Login now