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