@@ -1,145 +1,149 | |||||
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 => 3.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 => /#{Issue.find(1).subject}/, |
|
51 | :content => /#{Issue.find(1).subject}/, | |
52 | } |
|
52 | } | |
53 | } |
|
53 | } | |
54 | } |
|
54 | } | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | def test_global_index |
|
57 | def test_global_index | |
58 | get :index |
|
58 | get :index | |
59 | assert_response :success |
|
59 | assert_response :success | |
60 | assert_template 'index' |
|
60 | assert_template 'index' | |
61 | assert_not_nil assigns(:events_by_day) |
|
61 | assert_not_nil assigns(:events_by_day) | |
62 |
|
62 | |||
63 | assert_tag :tag => "h3", |
|
63 | assert_tag :tag => "h3", | |
64 | :content => /#{5.day.ago.to_date.day}/, |
|
64 | :content => /#{5.day.ago.to_date.day}/, | |
65 | :sibling => { :tag => "dl", |
|
65 | :sibling => { :tag => "dl", | |
66 | :child => { :tag => "dt", |
|
66 | :child => { :tag => "dt", | |
67 | :attributes => { :class => /issue/ }, |
|
67 | :attributes => { :class => /issue/ }, | |
68 | :child => { :tag => "a", |
|
68 | :child => { :tag => "a", | |
69 | :content => /#{Issue.find(5).subject}/, |
|
69 | :content => /#{Issue.find(5).subject}/, | |
70 | } |
|
70 | } | |
71 | } |
|
71 | } | |
72 | } |
|
72 | } | |
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | def test_user_index |
|
75 | def test_user_index | |
|
76 | @request.session[:user_id] = 1 | |||
76 | get :index, :user_id => 2 |
|
77 | get :index, :user_id => 2 | |
77 | assert_response :success |
|
78 | assert_response :success | |
78 | assert_template 'index' |
|
79 | assert_template 'index' | |
79 | assert_not_nil assigns(:events_by_day) |
|
80 | assert_not_nil assigns(:events_by_day) | |
80 |
|
81 | |||
81 | assert_select 'h2 a[href=/users/2]', :text => 'John Smith' |
|
82 | assert_select 'h2 a[href=/users/2]', :text => 'John Smith' | |
82 |
|
83 | |||
|
84 | i1 = Issue.find(1) | |||
|
85 | d1 = User.find(1).time_to_date(i1.created_on) | |||
|
86 | ||||
83 | assert_tag :tag => "h3", |
|
87 | assert_tag :tag => "h3", | |
84 |
:content => /#{ |
|
88 | :content => /#{d1.day}/, | |
85 | :sibling => { :tag => "dl", |
|
89 | :sibling => { :tag => "dl", | |
86 | :child => { :tag => "dt", |
|
90 | :child => { :tag => "dt", | |
87 | :attributes => { :class => /issue/ }, |
|
91 | :attributes => { :class => /issue/ }, | |
88 | :child => { :tag => "a", |
|
92 | :child => { :tag => "a", | |
89 | :content => /#{Issue.find(1).subject}/, |
|
93 | :content => /#{Issue.find(1).subject}/, | |
90 | } |
|
94 | } | |
91 | } |
|
95 | } | |
92 | } |
|
96 | } | |
93 | end |
|
97 | end | |
94 |
|
98 | |||
95 | def test_user_index_with_invalid_user_id_should_respond_404 |
|
99 | def test_user_index_with_invalid_user_id_should_respond_404 | |
96 | get :index, :user_id => 299 |
|
100 | get :index, :user_id => 299 | |
97 | assert_response 404 |
|
101 | assert_response 404 | |
98 | end |
|
102 | end | |
99 |
|
103 | |||
100 | def test_index_atom_feed |
|
104 | def test_index_atom_feed | |
101 | get :index, :format => 'atom', :with_subprojects => 0 |
|
105 | get :index, :format => 'atom', :with_subprojects => 0 | |
102 | assert_response :success |
|
106 | assert_response :success | |
103 | assert_template 'common/feed' |
|
107 | assert_template 'common/feed' | |
104 |
|
108 | |||
105 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
109 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | |
106 | :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'} |
|
110 | :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'} | |
107 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
111 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | |
108 | :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'} |
|
112 | :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'} | |
109 |
|
113 | |||
110 | assert_tag :tag => 'entry', :child => { |
|
114 | assert_tag :tag => 'entry', :child => { | |
111 | :tag => 'link', |
|
115 | :tag => 'link', | |
112 | :attributes => {:href => 'http://test.host/issues/11'}} |
|
116 | :attributes => {:href => 'http://test.host/issues/11'}} | |
113 | end |
|
117 | end | |
114 |
|
118 | |||
115 | def test_index_atom_feed_with_explicit_selection |
|
119 | def test_index_atom_feed_with_explicit_selection | |
116 | get :index, :format => 'atom', :with_subprojects => 0, |
|
120 | get :index, :format => 'atom', :with_subprojects => 0, | |
117 | :show_changesets => 1, |
|
121 | :show_changesets => 1, | |
118 | :show_documents => 1, |
|
122 | :show_documents => 1, | |
119 | :show_files => 1, |
|
123 | :show_files => 1, | |
120 | :show_issues => 1, |
|
124 | :show_issues => 1, | |
121 | :show_messages => 1, |
|
125 | :show_messages => 1, | |
122 | :show_news => 1, |
|
126 | :show_news => 1, | |
123 | :show_time_entries => 1, |
|
127 | :show_time_entries => 1, | |
124 | :show_wiki_edits => 1 |
|
128 | :show_wiki_edits => 1 | |
125 |
|
129 | |||
126 | assert_response :success |
|
130 | assert_response :success | |
127 | assert_template 'common/feed' |
|
131 | assert_template 'common/feed' | |
128 |
|
132 | |||
129 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
133 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | |
130 | :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} |
|
134 | :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} | |
131 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
135 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | |
132 | :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} |
|
136 | :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} | |
133 |
|
137 | |||
134 | assert_tag :tag => 'entry', :child => { |
|
138 | assert_tag :tag => 'entry', :child => { | |
135 | :tag => 'link', |
|
139 | :tag => 'link', | |
136 | :attributes => {:href => 'http://test.host/issues/11'}} |
|
140 | :attributes => {:href => 'http://test.host/issues/11'}} | |
137 | end |
|
141 | end | |
138 |
|
142 | |||
139 | def test_index_atom_feed_with_one_item_type |
|
143 | def test_index_atom_feed_with_one_item_type | |
140 | get :index, :format => 'atom', :show_issues => '1' |
|
144 | get :index, :format => 'atom', :show_issues => '1' | |
141 | assert_response :success |
|
145 | assert_response :success | |
142 | assert_template 'common/feed' |
|
146 | assert_template 'common/feed' | |
143 | assert_tag :tag => 'title', :content => /Issues/ |
|
147 | assert_tag :tag => 'title', :content => /Issues/ | |
144 | end |
|
148 | end | |
145 | end |
|
149 | end |
General Comments 0
You need to be logged in to leave comments.
Login now