##// END OF EJS Templates
Adds functional tests for ActivitiesController....
Jean-Philippe Lang -
r7866:dd501b1ba30a
parent child
Show More
@@ -1,97 +1,114
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 :auth_sources,
13 :auth_sources,
14 :journals, :journal_details
14 :journals, :journal_details
15
15
16
16
17 def test_project_index
17 def test_project_index
18 get :index, :id => 1, :with_subprojects => 0
18 get :index, :id => 1, :with_subprojects => 0
19 assert_response :success
19 assert_response :success
20 assert_template 'index'
20 assert_template 'index'
21 assert_not_nil assigns(:events_by_day)
21 assert_not_nil assigns(:events_by_day)
22
22
23 assert_tag :tag => "h3",
23 assert_tag :tag => "h3",
24 :content => /#{2.days.ago.to_date.day}/,
24 :content => /#{2.days.ago.to_date.day}/,
25 :sibling => { :tag => "dl",
25 :sibling => { :tag => "dl",
26 :child => { :tag => "dt",
26 :child => { :tag => "dt",
27 :attributes => { :class => /issue-edit/ },
27 :attributes => { :class => /issue-edit/ },
28 :child => { :tag => "a",
28 :child => { :tag => "a",
29 :content => /(#{IssueStatus.find(2).name})/,
29 :content => /(#{IssueStatus.find(2).name})/,
30 }
30 }
31 }
31 }
32 }
32 }
33 end
33 end
34
34
35 def test_project_index_with_invalid_project_id_should_respond_404
36 get :index, :id => 299
37 assert_response 404
38 end
39
35 def test_previous_project_index
40 def test_previous_project_index
36 get :index, :id => 1, :from => 3.days.ago.to_date
41 get :index, :id => 1, :from => 3.days.ago.to_date
37 assert_response :success
42 assert_response :success
38 assert_template 'index'
43 assert_template 'index'
39 assert_not_nil assigns(:events_by_day)
44 assert_not_nil assigns(:events_by_day)
40
45
41 assert_tag :tag => "h3",
46 assert_tag :tag => "h3",
42 :content => /#{3.day.ago.to_date.day}/,
47 :content => /#{3.day.ago.to_date.day}/,
43 :sibling => { :tag => "dl",
48 :sibling => { :tag => "dl",
44 :child => { :tag => "dt",
49 :child => { :tag => "dt",
45 :attributes => { :class => /issue/ },
50 :attributes => { :class => /issue/ },
46 :child => { :tag => "a",
51 :child => { :tag => "a",
47 :content => /#{Issue.find(1).subject}/,
52 :content => /#{Issue.find(1).subject}/,
48 }
53 }
49 }
54 }
50 }
55 }
51 end
56 end
52
57
53 def test_global_index
58 def test_global_index
54 get :index
59 get :index
55 assert_response :success
60 assert_response :success
56 assert_template 'index'
61 assert_template 'index'
57 assert_not_nil assigns(:events_by_day)
62 assert_not_nil assigns(:events_by_day)
58
63
59 assert_tag :tag => "h3",
64 assert_tag :tag => "h3",
60 :content => /#{5.day.ago.to_date.day}/,
65 :content => /#{5.day.ago.to_date.day}/,
61 :sibling => { :tag => "dl",
66 :sibling => { :tag => "dl",
62 :child => { :tag => "dt",
67 :child => { :tag => "dt",
63 :attributes => { :class => /issue/ },
68 :attributes => { :class => /issue/ },
64 :child => { :tag => "a",
69 :child => { :tag => "a",
65 :content => /#{Issue.find(5).subject}/,
70 :content => /#{Issue.find(5).subject}/,
66 }
71 }
67 }
72 }
68 }
73 }
69 end
74 end
70
75
71 def test_user_index
76 def test_user_index
72 get :index, :user_id => 2
77 get :index, :user_id => 2
73 assert_response :success
78 assert_response :success
74 assert_template 'index'
79 assert_template 'index'
75 assert_not_nil assigns(:events_by_day)
80 assert_not_nil assigns(:events_by_day)
76
81
77 assert_tag :tag => "h3",
82 assert_tag :tag => "h3",
78 :content => /#{3.day.ago.to_date.day}/,
83 :content => /#{3.day.ago.to_date.day}/,
79 :sibling => { :tag => "dl",
84 :sibling => { :tag => "dl",
80 :child => { :tag => "dt",
85 :child => { :tag => "dt",
81 :attributes => { :class => /issue/ },
86 :attributes => { :class => /issue/ },
82 :child => { :tag => "a",
87 :child => { :tag => "a",
83 :content => /#{Issue.find(1).subject}/,
88 :content => /#{Issue.find(1).subject}/,
84 }
89 }
85 }
90 }
86 }
91 }
87 end
92 end
88
93
94 def test_user_index_with_invalid_user_id_should_respond_404
95 get :index, :user_id => 299
96 assert_response 404
97 end
98
89 def test_index_atom_feed
99 def test_index_atom_feed
90 get :index, :format => 'atom'
100 get :index, :format => 'atom'
91 assert_response :success
101 assert_response :success
92 assert_template 'common/feed.atom'
102 assert_template 'common/feed.atom'
93 assert_tag :tag => 'entry', :child => {
103 assert_tag :tag => 'entry', :child => {
94 :tag => 'link',
104 :tag => 'link',
95 :attributes => {:href => 'http://test.host/issues/11'}}
105 :attributes => {:href => 'http://test.host/issues/11'}}
96 end
106 end
107
108 def test_index_atom_feed_with_one_item_type
109 get :index, :format => 'atom', :show_issues => '1'
110 assert_response :success
111 assert_template 'common/feed.atom'
112 assert_tag :tag => 'title', :content => /Issues/
113 end
97 end
114 end
General Comments 0
You need to be logged in to leave comments. Login now