@@ -76,14 +76,8 class ReportsController < ApplicationController | |||
|
76 | 76 | @rows = @project.descendants.visible |
|
77 | 77 | @data = Issue.by_subproject(@project) || [] |
|
78 | 78 | @report_title = l(:field_subproject) |
|
79 |
e |
|
|
80 | ||
|
81 | respond_to do |format| | |
|
82 | if @field | |
|
83 | format.html {} | |
|
84 | else | |
|
85 | format.html { redirect_to :action => 'issue_report', :id => @project } | |
|
86 | end | |
|
79 | else | |
|
80 | render_404 | |
|
87 | 81 | end |
|
88 | 82 | end |
|
89 | 83 |
@@ -27,10 +27,8 class MessagesControllerTest < Redmine::ControllerTest | |||
|
27 | 27 | def test_show |
|
28 | 28 | get :show, :board_id => 1, :id => 1 |
|
29 | 29 | assert_response :success |
|
30 | assert_template 'show' | |
|
31 | assert_not_nil assigns(:board) | |
|
32 | assert_not_nil assigns(:project) | |
|
33 | assert_not_nil assigns(:topic) | |
|
30 | ||
|
31 | assert_select 'h2', :text => 'First post' | |
|
34 | 32 | end |
|
35 | 33 | |
|
36 | 34 | def test_show_should_contain_reply_field_tags_for_quoting |
@@ -54,20 +52,20 class MessagesControllerTest < Redmine::ControllerTest | |||
|
54 | 52 | :board_id => 1) |
|
55 | 53 | end |
|
56 | 54 | end |
|
57 | get :show, :board_id => 1, :id => 1, :r => message.children.order('id').last.id | |
|
55 | reply_ids = message.children.map(&:id).sort | |
|
56 | ||
|
57 | get :show, :board_id => 1, :id => 1, :r => reply_ids.last | |
|
58 | 58 | assert_response :success |
|
59 | assert_template 'show' | |
|
60 | replies = assigns(:replies) | |
|
61 | assert_not_nil replies | |
|
62 | assert_not_include message.children.reorder('id').first, replies | |
|
63 | assert_include message.children.reorder('id').last, replies | |
|
59 | ||
|
60 | assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.last}#message-#{reply_ids.last}" | |
|
61 | assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.first}#message-#{reply_ids.first}", 0 | |
|
64 | 62 | end |
|
65 | 63 | |
|
66 | 64 | def test_show_with_reply_permission |
|
67 | 65 | @request.session[:user_id] = 2 |
|
68 | 66 | get :show, :board_id => 1, :id => 1 |
|
69 | 67 | assert_response :success |
|
70 | assert_template 'show' | |
|
68 | ||
|
71 | 69 | assert_select 'div#reply textarea#message_content' |
|
72 | 70 | end |
|
73 | 71 | |
@@ -85,7 +83,8 class MessagesControllerTest < Redmine::ControllerTest | |||
|
85 | 83 | @request.session[:user_id] = 2 |
|
86 | 84 | get :new, :board_id => 1 |
|
87 | 85 | assert_response :success |
|
88 | assert_template 'new' | |
|
86 | ||
|
87 | assert_select 'input[name=?]', 'message[subject]' | |
|
89 | 88 | end |
|
90 | 89 | |
|
91 | 90 | def test_get_new_with_invalid_board |
@@ -124,7 +123,8 class MessagesControllerTest < Redmine::ControllerTest | |||
|
124 | 123 | @request.session[:user_id] = 2 |
|
125 | 124 | get :edit, :board_id => 1, :id => 1 |
|
126 | 125 | assert_response :success |
|
127 | assert_template 'edit' | |
|
126 | ||
|
127 | assert_select 'input[name=?][value=?]', 'message[subject]', 'First post' | |
|
128 | 128 | end |
|
129 | 129 | |
|
130 | 130 | def test_post_edit |
@@ -193,7 +193,7 class MessagesControllerTest < Redmine::ControllerTest | |||
|
193 | 193 | xhr :get, :quote, :board_id => 1, :id => 3 |
|
194 | 194 | assert_response :success |
|
195 | 195 | assert_equal 'text/javascript', response.content_type |
|
196 | assert_template 'quote' | |
|
196 | ||
|
197 | 197 | assert_include 'RE: First post', response.body |
|
198 | 198 | assert_include '> An other reply', response.body |
|
199 | 199 | end |
@@ -204,7 +204,7 class MessagesControllerTest < Redmine::ControllerTest | |||
|
204 | 204 | :board_id => 1, |
|
205 | 205 | :message => {:subject => "", :content => "Previewed text"} |
|
206 | 206 | assert_response :success |
|
207 | assert_template 'common/_preview' | |
|
207 | assert_include 'Previewed text', response.body | |
|
208 | 208 | end |
|
209 | 209 | |
|
210 | 210 | def test_preview_edit |
@@ -214,6 +214,6 class MessagesControllerTest < Redmine::ControllerTest | |||
|
214 | 214 | :board_id => 1, |
|
215 | 215 | :message => {:subject => "", :content => "Previewed text"} |
|
216 | 216 | assert_response :success |
|
217 | assert_template 'common/_preview' | |
|
217 | assert_include 'Previewed text', response.body | |
|
218 | 218 | end |
|
219 | 219 | end |
@@ -28,13 +28,13 class MyControllerTest < Redmine::ControllerTest | |||
|
28 | 28 | def test_index |
|
29 | 29 | get :index |
|
30 | 30 | assert_response :success |
|
31 |
assert_ |
|
|
31 | assert_select 'h2', 'My page' | |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def test_page |
|
35 | 35 | get :page |
|
36 | 36 | assert_response :success |
|
37 |
assert_ |
|
|
37 | assert_select 'h2', 'My page' | |
|
38 | 38 | end |
|
39 | 39 | |
|
40 | 40 | def test_page_with_timelog_block |
@@ -65,9 +65,6 class MyControllerTest < Redmine::ControllerTest | |||
|
65 | 65 | def test_my_account_should_show_editable_custom_fields |
|
66 | 66 | get :account |
|
67 | 67 | assert_response :success |
|
68 | assert_template 'account' | |
|
69 | assert_equal User.find(2), assigns(:user) | |
|
70 | ||
|
71 | 68 | assert_select 'input[name=?]', 'user[custom_field_values][4]' |
|
72 | 69 | end |
|
73 | 70 | |
@@ -76,9 +73,6 class MyControllerTest < Redmine::ControllerTest | |||
|
76 | 73 | |
|
77 | 74 | get :account |
|
78 | 75 | assert_response :success |
|
79 | assert_template 'account' | |
|
80 | assert_equal User.find(2), assigns(:user) | |
|
81 | ||
|
82 | 76 | assert_select 'input[name=?]', 'user[custom_field_values][4]', 0 |
|
83 | 77 | end |
|
84 | 78 | |
@@ -108,7 +102,6 class MyControllerTest < Redmine::ControllerTest | |||
|
108 | 102 | |
|
109 | 103 | assert_redirected_to '/my/account' |
|
110 | 104 | user = User.find(2) |
|
111 | assert_equal user, assigns(:user) | |
|
112 | 105 | assert_equal "Joe", user.firstname |
|
113 | 106 | assert_equal "jsmith", user.login |
|
114 | 107 | assert_equal "0100562500", user.custom_value_for(4).value |
@@ -143,7 +136,6 class MyControllerTest < Redmine::ControllerTest | |||
|
143 | 136 | def test_get_destroy_should_display_the_destroy_confirmation |
|
144 | 137 | get :destroy |
|
145 | 138 | assert_response :success |
|
146 | assert_template 'destroy' | |
|
147 | 139 | assert_select 'form[action="/my/account/destroy"]' do |
|
148 | 140 | assert_select 'input[name=confirm]' |
|
149 | 141 | end |
@@ -154,7 +146,6 class MyControllerTest < Redmine::ControllerTest | |||
|
154 | 146 | post :destroy |
|
155 | 147 | end |
|
156 | 148 | assert_response :success |
|
157 | assert_template 'destroy' | |
|
158 | 149 | end |
|
159 | 150 | |
|
160 | 151 | def test_post_destroy_without_confirmation_should_destroy_account |
@@ -177,30 +168,36 class MyControllerTest < Redmine::ControllerTest | |||
|
177 | 168 | def test_change_password |
|
178 | 169 | get :password |
|
179 | 170 | assert_response :success |
|
180 | assert_template 'password' | |
|
171 | assert_select 'input[type=password][name=password]' | |
|
172 | assert_select 'input[type=password][name=new_password]' | |
|
173 | assert_select 'input[type=password][name=new_password_confirmation]' | |
|
174 | end | |
|
181 | 175 | |
|
182 | # non matching password confirmation | |
|
176 | def test_update_password | |
|
177 | post :password, :password => 'jsmith', | |
|
178 | :new_password => 'secret123', | |
|
179 | :new_password_confirmation => 'secret123' | |
|
180 | assert_redirected_to '/my/account' | |
|
181 | assert User.try_to_login('jsmith', 'secret123') | |
|
182 | end | |
|
183 | ||
|
184 | def test_update_password_with_non_matching_confirmation | |
|
183 | 185 | post :password, :password => 'jsmith', |
|
184 | 186 | :new_password => 'secret123', |
|
185 | 187 | :new_password_confirmation => 'secret1234' |
|
186 | 188 | assert_response :success |
|
187 | assert_template 'password' | |
|
188 | 189 | assert_select_error /Password doesn.*t match confirmation/ |
|
190 | assert User.try_to_login('jsmith', 'jsmith') | |
|
191 | end | |
|
189 | 192 | |
|
193 | def test_update_password_with_wrong_password | |
|
190 | 194 | # wrong password |
|
191 | 195 | post :password, :password => 'wrongpassword', |
|
192 | 196 | :new_password => 'secret123', |
|
193 | 197 | :new_password_confirmation => 'secret123' |
|
194 | 198 | assert_response :success |
|
195 | assert_template 'password' | |
|
196 | 199 | assert_equal 'Wrong password', flash[:error] |
|
197 | ||
|
198 | # good password | |
|
199 | post :password, :password => 'jsmith', | |
|
200 | :new_password => 'secret123', | |
|
201 | :new_password_confirmation => 'secret123' | |
|
202 | assert_redirected_to '/my/account' | |
|
203 | assert User.try_to_login('jsmith', 'secret123') | |
|
200 | assert User.try_to_login('jsmith', 'jsmith') | |
|
204 | 201 | end |
|
205 | 202 | |
|
206 | 203 | def test_change_password_should_redirect_if_user_cannot_change_its_password |
@@ -211,7 +208,7 class MyControllerTest < Redmine::ControllerTest | |||
|
211 | 208 | assert_redirected_to '/my/account' |
|
212 | 209 | end |
|
213 | 210 | |
|
214 |
def test_ |
|
|
211 | def test_update_password_should_send_security_notification | |
|
215 | 212 | ActionMailer::Base.deliveries.clear |
|
216 | 213 | post :password, :password => 'jsmith', |
|
217 | 214 | :new_password => 'secret123', |
@@ -227,7 +224,6 class MyControllerTest < Redmine::ControllerTest | |||
|
227 | 224 | def test_page_layout |
|
228 | 225 | get :page_layout |
|
229 | 226 | assert_response :success |
|
230 | assert_template 'page_layout' | |
|
231 | 227 | end |
|
232 | 228 | |
|
233 | 229 | def test_add_block |
@@ -29,16 +29,13 class NewsControllerTest < Redmine::ControllerTest | |||
|
29 | 29 | def test_index |
|
30 | 30 | get :index |
|
31 | 31 | assert_response :success |
|
32 | assert_template 'index' | |
|
33 | assert_not_nil assigns(:newss) | |
|
34 | assert_nil assigns(:project) | |
|
32 | assert_select 'h3 a', :text => 'eCookbook first release !' | |
|
35 | 33 | end |
|
36 | 34 | |
|
37 | 35 | def test_index_with_project |
|
38 | 36 | get :index, :project_id => 1 |
|
39 | 37 | assert_response :success |
|
40 | assert_template 'index' | |
|
41 | assert_not_nil assigns(:newss) | |
|
38 | assert_select 'h3 a', :text => 'eCookbook first release !' | |
|
42 | 39 | end |
|
43 | 40 | |
|
44 | 41 | def test_index_with_invalid_project_should_respond_with_404 |
@@ -49,8 +46,7 class NewsControllerTest < Redmine::ControllerTest | |||
|
49 | 46 | def test_show |
|
50 | 47 | get :show, :id => 1 |
|
51 | 48 | assert_response :success |
|
52 | assert_template 'show' | |
|
53 | assert_select 'h2', :text => /eCookbook first release/ | |
|
49 | assert_select 'h2', :text => 'eCookbook first release !' | |
|
54 | 50 | end |
|
55 | 51 | |
|
56 | 52 | def test_show_should_show_attachments |
@@ -71,7 +67,9 class NewsControllerTest < Redmine::ControllerTest | |||
|
71 | 67 | @request.session[:user_id] = 1 |
|
72 | 68 | get :show, :id => 1 |
|
73 | 69 | assert_response :success |
|
74 | assert_equal News.find(1).comments.to_a.sort_by(&:created_on).reverse, assigns(:comments) | |
|
70 | ||
|
71 | comments = css_select('#comments .wiki').map(&:text).map(&:strip) | |
|
72 | assert_equal ["This is an other comment", "my first comment"], comments | |
|
75 | 73 | end |
|
76 | 74 | |
|
77 | 75 | def test_show_not_found |
@@ -83,7 +81,7 class NewsControllerTest < Redmine::ControllerTest | |||
|
83 | 81 | @request.session[:user_id] = 2 |
|
84 | 82 | get :new, :project_id => 1 |
|
85 | 83 | assert_response :success |
|
86 | assert_template 'new' | |
|
84 | assert_select 'input[name=?]', 'news[title]' | |
|
87 | 85 | end |
|
88 | 86 | |
|
89 | 87 | def test_post_create |
@@ -126,9 +124,6 class NewsControllerTest < Redmine::ControllerTest | |||
|
126 | 124 | :description => 'This is the description', |
|
127 | 125 | :summary => '' } |
|
128 | 126 | assert_response :success |
|
129 | assert_template 'new' | |
|
130 | assert_not_nil assigns(:news) | |
|
131 | assert assigns(:news).new_record? | |
|
132 | 127 | assert_select_error /title cannot be blank/i |
|
133 | 128 | end |
|
134 | 129 | |
@@ -136,7 +131,7 class NewsControllerTest < Redmine::ControllerTest | |||
|
136 | 131 | @request.session[:user_id] = 2 |
|
137 | 132 | get :edit, :id => 1 |
|
138 | 133 | assert_response :success |
|
139 | assert_template 'edit' | |
|
134 | assert_select 'input[name=?][value=?]', 'news[title]', 'eCookbook first release !' | |
|
140 | 135 | end |
|
141 | 136 | |
|
142 | 137 | def test_put_update |
@@ -165,7 +160,6 class NewsControllerTest < Redmine::ControllerTest | |||
|
165 | 160 | @request.session[:user_id] = 2 |
|
166 | 161 | put :update, :id => 1, :news => { :description => '' } |
|
167 | 162 | assert_response :success |
|
168 | assert_template 'edit' | |
|
169 | 163 | assert_select_error /description cannot be blank/i |
|
170 | 164 | end |
|
171 | 165 |
@@ -32,25 +32,35 class PreviewsControllerTest < Redmine::ControllerTest | |||
|
32 | 32 | @request.session[:user_id] = 2 |
|
33 | 33 | post :issue, :project_id => '1', :issue => {:description => 'Foo'} |
|
34 | 34 | assert_response :success |
|
35 | assert_template 'previews/issue' | |
|
36 | assert_not_nil assigns(:description) | |
|
35 | assert_select 'fieldset' do | |
|
36 | assert_select 'legend', :text => 'Description' | |
|
37 | assert_select 'p', :text => 'Foo' | |
|
38 | end | |
|
37 | 39 | end |
|
38 | 40 | |
|
39 | def test_preview_issue_notes | |
|
41 | def test_preview_issue_notes_with_no_change_to_description | |
|
40 | 42 | @request.session[:user_id] = 2 |
|
41 | 43 | post :issue, :project_id => '1', :id => 1, |
|
42 | 44 | :issue => {:description => Issue.find(1).description, :notes => 'Foo'} |
|
43 | 45 | assert_response :success |
|
44 | assert_template 'previews/issue' | |
|
45 | assert_not_nil assigns(:notes) | |
|
46 | assert_select 'legend', :text => 'Description', :count => 0 | |
|
47 | assert_select 'legend', :text => 'Notes' | |
|
48 | end | |
|
49 | ||
|
50 | def test_preview_issue_notes_with_no_change_to_description | |
|
51 | @request.session[:user_id] = 2 | |
|
52 | post :issue, :project_id => '1', :id => 1, | |
|
53 | :issue => {:description => 'Changed description', :notes => 'Foo'} | |
|
54 | assert_response :success | |
|
55 | assert_select 'legend', :text => 'Description' | |
|
56 | assert_select 'legend', :text => 'Notes' | |
|
46 | 57 | end |
|
47 | 58 | |
|
48 | 59 | def test_preview_journal_notes_for_update |
|
49 | 60 | @request.session[:user_id] = 2 |
|
50 | 61 | post :issue, :project_id => '1', :id => 1, :notes => 'Foo' |
|
51 | 62 | assert_response :success |
|
52 | assert_template 'previews/issue' | |
|
53 | assert_not_nil assigns(:notes) | |
|
63 | assert_select 'legend', :text => 'Notes' | |
|
54 | 64 | assert_select 'p', :text => 'Foo' |
|
55 | 65 | end |
|
56 | 66 | |
@@ -66,8 +76,7 class PreviewsControllerTest < Redmine::ControllerTest | |||
|
66 | 76 | @request.session[:user_id] = 2 |
|
67 | 77 | post :issue, :project_id => '1', :id => 1, :issue => {:notes => 'notes', :project_id => 2} |
|
68 | 78 | assert_response :success |
|
69 | assert_not_nil assigns(:issue) | |
|
70 | assert_not_nil assigns(:notes) | |
|
79 | assert_select 'legend', :text => 'Notes' | |
|
71 | 80 | end |
|
72 | 81 | |
|
73 | 82 | def test_preview_new_news |
@@ -76,20 +85,15 class PreviewsControllerTest < Redmine::ControllerTest | |||
|
76 | 85 | :description => 'News description', |
|
77 | 86 | :summary => ''} |
|
78 | 87 | assert_response :success |
|
79 | assert_template 'common/_preview' | |
|
80 | 88 | assert_select 'fieldset.preview', :text => /News description/ |
|
81 | 89 | end |
|
82 | 90 | |
|
83 |
def test_existing |
|
|
91 | def test_preview_existing_news | |
|
84 | 92 | get :news, :project_id => 1, :id => 2, |
|
85 | 93 | :news => {:title => '', |
|
86 | 94 | :description => 'News description', |
|
87 | 95 | :summary => ''} |
|
88 | 96 | assert_response :success |
|
89 | assert_template 'common/_preview' | |
|
90 | assert_equal News.find(2), assigns(:previewed) | |
|
91 | assert_not_nil assigns(:attachments) | |
|
92 | ||
|
93 | 97 | assert_select 'fieldset.preview', :text => /News description/ |
|
94 | 98 | end |
|
95 | 99 | end |
@@ -86,7 +86,6 class PrincipalMembershipsControllerTest < Redmine::ControllerTest | |||
|
86 | 86 | assert_difference 'Member.count' do |
|
87 | 87 | xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2]}, :format => 'js' |
|
88 | 88 | assert_response :success |
|
89 | assert_template 'create' | |
|
90 | 89 | assert_equal 'text/javascript', response.content_type |
|
91 | 90 | end |
|
92 | 91 | member = Member.order('id DESC').first |
@@ -100,7 +99,6 class PrincipalMembershipsControllerTest < Redmine::ControllerTest | |||
|
100 | 99 | assert_no_difference 'Member.count' do |
|
101 | 100 | xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3]}, :format => 'js' |
|
102 | 101 | assert_response :success |
|
103 | assert_template 'create' | |
|
104 | 102 | assert_equal 'text/javascript', response.content_type |
|
105 | 103 | end |
|
106 | 104 | assert_include 'alert', response.body, "Alert message not sent" |
@@ -119,7 +117,6 class PrincipalMembershipsControllerTest < Redmine::ControllerTest | |||
|
119 | 117 | assert_no_difference 'Member.count' do |
|
120 | 118 | xhr :put, :update, :user_id => 2, :id => 1, :membership => {:role_ids => [2]}, :format => 'js' |
|
121 | 119 | assert_response :success |
|
122 | assert_template 'update' | |
|
123 | 120 | assert_equal 'text/javascript', response.content_type |
|
124 | 121 | end |
|
125 | 122 | assert_equal [2], Member.find(1).role_ids |
@@ -138,7 +135,6 class PrincipalMembershipsControllerTest < Redmine::ControllerTest | |||
|
138 | 135 | assert_difference 'Member.count', -1 do |
|
139 | 136 | xhr :delete, :destroy, :user_id => 2, :id => 1 |
|
140 | 137 | assert_response :success |
|
141 | assert_template 'destroy' | |
|
142 | 138 | assert_equal 'text/javascript', response.content_type |
|
143 | 139 | end |
|
144 | 140 | assert_nil Member.find_by_id(1) |
@@ -161,7 +157,6 class PrincipalMembershipsControllerTest < Redmine::ControllerTest | |||
|
161 | 157 | assert_difference 'Group.find(10).members.count' do |
|
162 | 158 | xhr :post, :create, :group_id => 10, :membership => {:project_ids => [2], :role_ids => ['1', '2']} |
|
163 | 159 | assert_response :success |
|
164 | assert_template 'create' | |
|
165 | 160 | assert_equal 'text/javascript', response.content_type |
|
166 | 161 | end |
|
167 | 162 | assert_match /OnlineStore/, response.body |
@@ -171,7 +166,6 class PrincipalMembershipsControllerTest < Redmine::ControllerTest | |||
|
171 | 166 | assert_no_difference 'Group.find(10).members.count' do |
|
172 | 167 | xhr :post, :create, :group_id => 10, :membership => {:project_ids => [999], :role_ids => ['1', '2']} |
|
173 | 168 | assert_response :success |
|
174 | assert_template 'create' | |
|
175 | 169 | assert_equal 'text/javascript', response.content_type |
|
176 | 170 | end |
|
177 | 171 | assert_match /alert/, response.body, "Alert message not sent" |
@@ -187,7 +181,6 class PrincipalMembershipsControllerTest < Redmine::ControllerTest | |||
|
187 | 181 | assert_no_difference 'Group.find(10).members.count' do |
|
188 | 182 | xhr :post, :update, :group_id => 10, :id => 6, :membership => {:role_ids => ['1', '3']} |
|
189 | 183 | assert_response :success |
|
190 | assert_template 'update' | |
|
191 | 184 | assert_equal 'text/javascript', response.content_type |
|
192 | 185 | end |
|
193 | 186 | end |
@@ -202,7 +195,6 class PrincipalMembershipsControllerTest < Redmine::ControllerTest | |||
|
202 | 195 | assert_difference 'Group.find(10).members.count', -1 do |
|
203 | 196 | xhr :delete, :destroy, :group_id => 10, :id => 6 |
|
204 | 197 | assert_response :success |
|
205 | assert_template 'destroy' | |
|
206 | 198 | assert_equal 'text/javascript', response.content_type |
|
207 | 199 | end |
|
208 | 200 | end |
@@ -33,10 +33,6 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
33 | 33 | def test_index_by_anonymous_should_not_show_private_projects |
|
34 | 34 | get :index |
|
35 | 35 | assert_response :success |
|
36 | assert_template 'index' | |
|
37 | projects = assigns(:projects) | |
|
38 | assert_not_nil projects | |
|
39 | assert projects.all?(&:is_public?) | |
|
40 | 36 | |
|
41 | 37 | assert_select 'ul' do |
|
42 | 38 | assert_select 'li' do |
@@ -52,7 +48,6 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
52 | 48 | def test_index_atom |
|
53 | 49 | get :index, :format => 'atom' |
|
54 | 50 | assert_response :success |
|
55 | assert_template 'common/feed' | |
|
56 | 51 | assert_select 'feed>title', :text => 'Redmine: Latest projects' |
|
57 | 52 | assert_select 'feed>entry', :count => Project.visible(User.current).count |
|
58 | 53 | end |
@@ -60,7 +55,6 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
60 | 55 | test "#index by non-admin user with view_time_entries permission should show overall spent time link" do |
|
61 | 56 | @request.session[:user_id] = 3 |
|
62 | 57 | get :index |
|
63 | assert_template 'index' | |
|
64 | 58 | assert_select 'a[href=?]', '/time_entries' |
|
65 | 59 | end |
|
66 | 60 | |
@@ -71,15 +65,14 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
71 | 65 | @request.session[:user_id] = 3 |
|
72 | 66 | |
|
73 | 67 | get :index |
|
74 | assert_template 'index' | |
|
75 | 68 | assert_select 'a[href=?]', '/time_entries', 0 |
|
76 | 69 | end |
|
77 | 70 | |
|
78 | 71 | test "#index by non-admin user with permission should show add project link" do |
|
79 | 72 | Role.find(1).add_permission! :add_project |
|
80 | 73 | @request.session[:user_id] = 2 |
|
74 | ||
|
81 | 75 | get :index |
|
82 | assert_template 'index' | |
|
83 | 76 | assert_select 'a[href=?]', '/projects/new' |
|
84 | 77 | end |
|
85 | 78 | |
@@ -88,7 +81,8 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
88 | 81 | |
|
89 | 82 | get :new |
|
90 | 83 | assert_response :success |
|
91 | assert_template 'new' | |
|
84 | assert_select 'input[name=?]', 'project[name]' | |
|
85 | assert_select 'select[name=?]', 'project[parent_id]' | |
|
92 | 86 | end |
|
93 | 87 | |
|
94 | 88 | test "#new by non-admin user with add_project permission should accept get" do |
@@ -97,7 +91,7 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
97 | 91 | |
|
98 | 92 | get :new |
|
99 | 93 | assert_response :success |
|
100 | assert_template 'new' | |
|
94 | assert_select 'input[name=?]', 'project[name]' | |
|
101 | 95 | assert_select 'select[name=?]', 'project[parent_id]', 0 |
|
102 | 96 | end |
|
103 | 97 | |
@@ -108,7 +102,6 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
108 | 102 | |
|
109 | 103 | get :new, :parent_id => 'ecookbook' |
|
110 | 104 | assert_response :success |
|
111 | assert_template 'new' | |
|
112 | 105 | |
|
113 | 106 | assert_select 'select[name=?]', 'project[parent_id]' do |
|
114 | 107 | # parent project selected |
@@ -215,6 +208,7 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
215 | 208 | |
|
216 | 209 | test "#create by non-admin user with add_project permission should fail with parent_id" do |
|
217 | 210 | Role.non_member.add_permission! :add_project |
|
211 | User.find(9).update! :language => 'en' | |
|
218 | 212 | @request.session[:user_id] = 9 |
|
219 | 213 | |
|
220 | 214 | assert_no_difference 'Project.count' do |
@@ -227,9 +221,7 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
227 | 221 | } |
|
228 | 222 | end |
|
229 | 223 | assert_response :success |
|
230 | project = assigns(:project) | |
|
231 | assert_kind_of Project, project | |
|
232 | assert_not_equal [], project.errors[:parent_id] | |
|
224 | assert_select_error /Subproject of is invalid/ | |
|
233 | 225 | end |
|
234 | 226 | |
|
235 | 227 | test "#create by non-admin user with add_subprojects permission should create a project with a parent_id" do |
@@ -246,6 +238,7 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
246 | 238 | } |
|
247 | 239 | assert_redirected_to '/projects/blog/settings' |
|
248 | 240 | project = Project.find_by_name('blog') |
|
241 | assert_equal 1, project.parent_id | |
|
249 | 242 | end |
|
250 | 243 | |
|
251 | 244 | test "#create by non-admin user with add_subprojects permission should fail without parent_id" do |
@@ -262,9 +255,7 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
262 | 255 | } |
|
263 | 256 | end |
|
264 | 257 | assert_response :success |
|
265 | project = assigns(:project) | |
|
266 | assert_kind_of Project, project | |
|
267 | assert_not_equal [], project.errors[:parent_id] | |
|
258 | assert_select_error /Subproject of is invalid/ | |
|
268 | 259 | end |
|
269 | 260 | |
|
270 | 261 | test "#create by non-admin user with add_subprojects permission should fail with unauthorized parent_id" do |
@@ -283,9 +274,7 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
283 | 274 | } |
|
284 | 275 | end |
|
285 | 276 | assert_response :success |
|
286 | project = assigns(:project) | |
|
287 | assert_kind_of Project, project | |
|
288 | assert_not_equal [], project.errors[:parent_id] | |
|
277 | assert_select_error /Subproject of is invalid/ | |
|
289 | 278 | end |
|
290 | 279 | |
|
291 | 280 | def test_create_subproject_with_inherit_members_should_inherit_members |
@@ -318,26 +307,23 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
318 | 307 | } |
|
319 | 308 | end |
|
320 | 309 | assert_response :success |
|
321 | project = assigns(:project) | |
|
322 | assert_equal %w(issue_tracking news), project.enabled_module_names.sort | |
|
310 | %w(issue_tracking news).each do |mod| | |
|
311 | assert_select 'input[name=?][value=?][checked=checked]', 'project[enabled_module_names][]', mod | |
|
312 | end | |
|
313 | assert_select 'input[name=?][checked=checked]', 'project[enabled_module_names][]', :count => 2 | |
|
323 | 314 | end |
|
324 | 315 | end |
|
325 | 316 | |
|
326 | 317 | def test_show_by_id |
|
327 | 318 | get :show, :id => 1 |
|
328 | 319 | assert_response :success |
|
329 | assert_template 'show' | |
|
330 | assert_not_nil assigns(:project) | |
|
320 | assert_select '#header h1', :text => "eCookbook" | |
|
331 | 321 | end |
|
332 | 322 | |
|
333 | 323 | def test_show_by_identifier |
|
334 | 324 | get :show, :id => 'ecookbook' |
|
335 | 325 | assert_response :success |
|
336 | assert_template 'show' | |
|
337 | assert_not_nil assigns(:project) | |
|
338 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) | |
|
339 | ||
|
340 | assert_select 'li', :text => /Development status/ | |
|
326 | assert_select '#header h1', :text => "eCookbook" | |
|
341 | 327 | end |
|
342 | 328 | |
|
343 | 329 | def test_show_should_not_display_empty_sidebar |
@@ -350,12 +336,18 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
350 | 336 | assert_select '#main.nosidebar' |
|
351 | 337 | end |
|
352 | 338 | |
|
339 | def test_show_should_display_visible_custom_fields | |
|
340 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, true | |
|
341 | get :show, :id => 'ecookbook' | |
|
342 | assert_response :success | |
|
343 | ||
|
344 | assert_select 'li', :text => /Development status/ | |
|
345 | end | |
|
346 | ||
|
353 | 347 | def test_show_should_not_display_hidden_custom_fields |
|
354 | 348 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, false |
|
355 | 349 | get :show, :id => 'ecookbook' |
|
356 | 350 | assert_response :success |
|
357 | assert_template 'show' | |
|
358 | assert_not_nil assigns(:project) | |
|
359 | 351 | |
|
360 | 352 | assert_select 'li', :text => /Development status/, :count => 0 |
|
361 | 353 | end |
@@ -386,9 +378,6 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
386 | 378 | project.custom_values.first.update_attribute(:value, nil) |
|
387 | 379 | get :show, :id => 'ecookbook' |
|
388 | 380 | assert_response :success |
|
389 | assert_template 'show' | |
|
390 | assert_not_nil assigns(:project) | |
|
391 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) | |
|
392 | 381 | end |
|
393 | 382 | |
|
394 | 383 | def show_archived_project_should_be_denied |
@@ -397,14 +386,13 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
397 | 386 | |
|
398 | 387 | get :show, :id => 'ecookbook' |
|
399 | 388 | assert_response 403 |
|
400 | assert_nil assigns(:project) | |
|
401 | 389 | assert_select 'p', :text => /archived/ |
|
390 | assert_not_include project.name, response.body | |
|
402 | 391 | end |
|
403 | 392 | |
|
404 | 393 | def test_show_should_not_show_private_subprojects_that_are_not_visible |
|
405 | 394 | get :show, :id => 'ecookbook' |
|
406 | 395 | assert_response :success |
|
407 | assert_template 'show' | |
|
408 | 396 | assert_select 'a', :text => /Private child/, :count => 0 |
|
409 | 397 | end |
|
410 | 398 | |
@@ -412,7 +400,6 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
412 | 400 | @request.session[:user_id] = 2 # manager who is a member of the private subproject |
|
413 | 401 | get :show, :id => 'ecookbook' |
|
414 | 402 | assert_response :success |
|
415 | assert_template 'show' | |
|
416 | 403 | assert_select 'a', :text => /Private child/ |
|
417 | 404 | end |
|
418 | 405 | |
@@ -420,14 +407,14 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
420 | 407 | @request.session[:user_id] = 2 # manager |
|
421 | 408 | get :settings, :id => 1 |
|
422 | 409 | assert_response :success |
|
423 | assert_template 'settings' | |
|
410 | ||
|
411 | assert_select 'input[name=?]', 'project[name]' | |
|
424 | 412 | end |
|
425 | 413 | |
|
426 | 414 | def test_settings_of_subproject |
|
427 | 415 | @request.session[:user_id] = 2 |
|
428 | 416 | get :settings, :id => 'private-child' |
|
429 | 417 | assert_response :success |
|
430 | assert_template 'settings' | |
|
431 | 418 | |
|
432 | 419 | assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]' |
|
433 | 420 | end |
@@ -454,7 +441,6 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
454 | 441 | |
|
455 | 442 | get :settings, :id => 1 |
|
456 | 443 | assert_response :success |
|
457 | assert_template 'settings' | |
|
458 | 444 | |
|
459 | 445 | assert_select 'form[action=?]', '/projects/ecookbook/wiki' do |
|
460 | 446 | assert_select 'input[name=?]', 'wiki[start_page]' |
@@ -474,7 +460,6 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
474 | 460 | @request.session[:user_id] = 2 # manager |
|
475 | 461 | post :update, :id => 1, :project => {:name => ''} |
|
476 | 462 | assert_response :success |
|
477 | assert_template 'settings' | |
|
478 | 463 | assert_select_error /name cannot be blank/i |
|
479 | 464 | end |
|
480 | 465 | |
@@ -521,8 +506,8 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
521 | 506 | assert_no_difference 'Project.count' do |
|
522 | 507 | delete :destroy, :id => 2 |
|
523 | 508 | assert_response :success |
|
524 | assert_template 'destroy' | |
|
525 | 509 | end |
|
510 | assert_select '.warning', :text => /Are you sure you want to delete this project/ | |
|
526 | 511 | end |
|
527 | 512 | |
|
528 | 513 | def test_destroy_without_confirmation_should_show_confirmation_with_subprojects |
@@ -531,7 +516,6 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
531 | 516 | assert_no_difference 'Project.count' do |
|
532 | 517 | delete :destroy, :id => 1 |
|
533 | 518 | assert_response :success |
|
534 | assert_template 'destroy' | |
|
535 | 519 | end |
|
536 | 520 | assert_select 'strong', |
|
537 | 521 | :text => ['Private child of eCookbook', |
@@ -603,13 +587,12 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
603 | 587 | |
|
604 | 588 | def test_get_copy |
|
605 | 589 | @request.session[:user_id] = 1 # admin |
|
606 | get :copy, :id => 1 | |
|
590 | orig = Project.find(1) | |
|
591 | ||
|
592 | get :copy, :id => orig.id | |
|
607 | 593 | assert_response :success |
|
608 | assert_template 'copy' | |
|
609 | assert assigns(:project) | |
|
610 | assert_equal Project.find(1).description, assigns(:project).description | |
|
611 | assert_nil assigns(:project).id | |
|
612 | 594 | |
|
595 | assert_select 'textarea[name=?]', 'project[description]', :text => orig.description | |
|
613 | 596 | assert_select 'input[name=?][value=?]', 'project[enabled_module_names][]', 'issue_tracking', 1 |
|
614 | 597 | end |
|
615 | 598 | |
@@ -667,7 +650,7 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
667 | 650 | @request.session[:user_id] = 1 |
|
668 | 651 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => ''} |
|
669 | 652 | assert_response :success |
|
670 | assert_template 'copy' | |
|
653 | assert_select_error /Identifier cannot be blank/ | |
|
671 | 654 | end |
|
672 | 655 | |
|
673 | 656 | def test_jump_should_redirect_to_active_tab |
@@ -678,13 +661,11 class ProjectsControllerTest < Redmine::ControllerTest | |||
|
678 | 661 | def test_jump_should_not_redirect_to_inactive_tab |
|
679 | 662 | get :show, :id => 3, :jump => 'documents' |
|
680 | 663 | assert_response :success |
|
681 | assert_template 'show' | |
|
682 | 664 | end |
|
683 | 665 | |
|
684 | 666 | def test_jump_should_not_redirect_to_unknown_tab |
|
685 | 667 | get :show, :id => 3, :jump => 'foobar' |
|
686 | 668 | assert_response :success |
|
687 | assert_template 'show' | |
|
688 | 669 | end |
|
689 | 670 | |
|
690 | 671 | def test_body_should_have_project_css_class |
@@ -34,7 +34,7 class QueriesControllerTest < Redmine::ControllerTest | |||
|
34 | 34 | @request.session[:user_id] = 2 |
|
35 | 35 | get :new, :project_id => 1 |
|
36 | 36 | assert_response :success |
|
37 | assert_template 'new' | |
|
37 | ||
|
38 | 38 | assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]' |
|
39 | 39 | assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])' |
|
40 | 40 | assert_select 'select[name=?]', 'c[]' do |
@@ -47,7 +47,7 class QueriesControllerTest < Redmine::ControllerTest | |||
|
47 | 47 | @request.session[:user_id] = 2 |
|
48 | 48 | get :new |
|
49 | 49 | assert_response :success |
|
50 | assert_template 'new' | |
|
50 | ||
|
51 | 51 | assert_select 'input[name=?]', 'query[visibility]', 0 |
|
52 | 52 | assert_select 'input[name=query_is_for_all][type=checkbox][checked]:not([disabled])' |
|
53 | 53 | end |
@@ -169,7 +169,7 class QueriesControllerTest < Redmine::ControllerTest | |||
|
169 | 169 | post :create, :project_id => 'ecookbook', :query => {:name => ''} |
|
170 | 170 | end |
|
171 | 171 | assert_response :success |
|
172 | assert_template 'new' | |
|
172 | ||
|
173 | 173 | assert_select 'input[name=?]', 'query[name]' |
|
174 | 174 | end |
|
175 | 175 | |
@@ -294,7 +294,7 class QueriesControllerTest < Redmine::ControllerTest | |||
|
294 | 294 | @request.session[:user_id] = 1 |
|
295 | 295 | get :edit, :id => 4 |
|
296 | 296 | assert_response :success |
|
297 | assert_template 'edit' | |
|
297 | ||
|
298 | 298 | assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]' |
|
299 | 299 | assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked]' |
|
300 | 300 | end |
@@ -303,7 +303,7 class QueriesControllerTest < Redmine::ControllerTest | |||
|
303 | 303 | @request.session[:user_id] = 3 |
|
304 | 304 | get :edit, :id => 3 |
|
305 | 305 | assert_response :success |
|
306 | assert_template 'edit' | |
|
306 | ||
|
307 | 307 | assert_select 'input[name=?]', 'query[visibility]', 0 |
|
308 | 308 | assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked]' |
|
309 | 309 | end |
@@ -312,7 +312,7 class QueriesControllerTest < Redmine::ControllerTest | |||
|
312 | 312 | @request.session[:user_id] = 3 |
|
313 | 313 | get :edit, :id => 2 |
|
314 | 314 | assert_response :success |
|
315 | assert_template 'edit' | |
|
315 | ||
|
316 | 316 | assert_select 'input[name=?]', 'query[visibility]', 0 |
|
317 | 317 | assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked])' |
|
318 | 318 | end |
@@ -321,7 +321,7 class QueriesControllerTest < Redmine::ControllerTest | |||
|
321 | 321 | @request.session[:user_id] = 2 |
|
322 | 322 | get :edit, :id => 1 |
|
323 | 323 | assert_response :success |
|
324 | assert_template 'edit' | |
|
324 | ||
|
325 | 325 | assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]' |
|
326 | 326 | assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked])' |
|
327 | 327 | end |
@@ -330,7 +330,7 class QueriesControllerTest < Redmine::ControllerTest | |||
|
330 | 330 | @request.session[:user_id] = 1 |
|
331 | 331 | get :edit, :id => 5 |
|
332 | 332 | assert_response :success |
|
333 | assert_template 'edit' | |
|
333 | ||
|
334 | 334 | assert_select 'select[name=?]', 'query[sort_criteria][0][]' do |
|
335 | 335 | assert_select 'option[value=priority][selected=selected]' |
|
336 | 336 | assert_select 'option[value=desc][selected=selected]' |
@@ -381,7 +381,7 class QueriesControllerTest < Redmine::ControllerTest | |||
|
381 | 381 | @request.session[:user_id] = 1 |
|
382 | 382 | put :update, :id => 4, :query => {:name => ''} |
|
383 | 383 | assert_response :success |
|
384 | assert_template 'edit' | |
|
384 | assert_select_error /Name cannot be blank/ | |
|
385 | 385 | end |
|
386 | 386 | |
|
387 | 387 | def test_destroy |
@@ -395,7 +395,6 class QueriesControllerTest < Redmine::ControllerTest | |||
|
395 | 395 | @request.session[:user_id] = 2 |
|
396 | 396 | get :new, :subject => 'foo/bar' |
|
397 | 397 | assert_response :success |
|
398 | assert_template 'new' | |
|
399 | 398 | assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body |
|
400 | 399 | end |
|
401 | 400 | end |
@@ -29,28 +29,13 class ReportsControllerTest < Redmine::ControllerTest | |||
|
29 | 29 | |
|
30 | 30 | def test_get_issue_report |
|
31 | 31 | get :issue_report, :id => 1 |
|
32 | ||
|
33 | 32 | assert_response :success |
|
34 | assert_template 'issue_report' | |
|
35 | ||
|
36 | [:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to, | |
|
37 | :issues_by_author, :issues_by_subproject, :issues_by_priority].each do |ivar| | |
|
38 | assert_not_nil assigns(ivar) | |
|
39 | end | |
|
40 | ||
|
41 | assert_equal IssuePriority.all.reverse, assigns(:priorities) | |
|
42 | 33 | end |
|
43 | 34 | |
|
44 | 35 | def test_get_issue_report_details |
|
45 | 36 | %w(tracker version priority category assigned_to author subproject).each do |detail| |
|
46 | 37 | get :issue_report_details, :id => 1, :detail => detail |
|
47 | ||
|
48 | 38 | assert_response :success |
|
49 | assert_template 'issue_report_details' | |
|
50 | assert_not_nil assigns(:field) | |
|
51 | assert_not_nil assigns(:rows) | |
|
52 | assert_not_nil assigns(:data) | |
|
53 | assert_not_nil assigns(:report_title) | |
|
54 | 39 | end |
|
55 | 40 | end |
|
56 | 41 | |
@@ -72,14 +57,8 class ReportsControllerTest < Redmine::ControllerTest | |||
|
72 | 57 | end |
|
73 | 58 | end |
|
74 | 59 | |
|
75 | def test_get_issue_report_details_by_priority | |
|
76 | get :issue_report_details, :id => 1, :detail => 'priority' | |
|
77 | assert_equal IssuePriority.all.reverse, assigns(:rows) | |
|
78 | end | |
|
79 | ||
|
80 | 60 | def test_get_issue_report_details_with_an_invalid_detail |
|
81 | 61 | get :issue_report_details, :id => 1, :detail => 'invalid' |
|
82 | ||
|
83 | assert_redirected_to '/projects/ecookbook/issues/report' | |
|
62 | assert_response 404 | |
|
84 | 63 | end |
|
85 | 64 | end |
General Comments 0
You need to be logged in to leave comments.
Login now