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