@@ -46,7 +46,7 | |||||
46 | <% end %> |
|
46 | <% end %> | |
47 |
|
47 | |||
48 | <% content_for :sidebar do %> |
|
48 | <% content_for :sidebar do %> | |
49 | <%= form_tag({}, :method => :get) do %> |
|
49 | <%= form_tag({}, :method => :get, :id => 'activity_scope_form') do %> | |
50 | <h3><%= l(:label_activity) %></h3> |
|
50 | <h3><%= l(:label_activity) %></h3> | |
51 | <ul> |
|
51 | <ul> | |
52 | <% @activity.event_types.each do |t| %> |
|
52 | <% @activity.event_types.each do |t| %> |
@@ -35,7 +35,7 | |||||
35 | </tr></thead> |
|
35 | </tr></thead> | |
36 | <tbody> |
|
36 | <tbody> | |
37 | <% @topics.each do |topic| %> |
|
37 | <% @topics.each do |topic| %> | |
38 | <tr class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"> |
|
38 | <tr id="message-<%= topic.id %>" class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"> | |
39 | <td class="subject"><%= link_to topic.subject, board_message_path(@board, topic) %></td> |
|
39 | <td class="subject"><%= link_to topic.subject, board_message_path(@board, topic) %></td> | |
40 | <td class="author"><%= link_to_user(topic.author) %></td> |
|
40 | <td class="author"><%= link_to_user(topic.author) %></td> | |
41 | <td class="created_on"><%= format_time(topic.created_on) %></td> |
|
41 | <td class="created_on"><%= format_time(topic.created_on) %></td> |
@@ -3,6 +3,7 | |||||
3 | <% if @conflict_journals.present? %> |
|
3 | <% if @conflict_journals.present? %> | |
4 | <div class="conflict-details"> |
|
4 | <div class="conflict-details"> | |
5 | <% @conflict_journals.sort_by(&:id).each do |journal| %> |
|
5 | <% @conflict_journals.sort_by(&:id).each do |journal| %> | |
|
6 | <div class="conflict-journal"> | |||
6 | <p><%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %></p> |
|
7 | <p><%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %></p> | |
7 | <% if journal.details.any? %> |
|
8 | <% if journal.details.any? %> | |
8 | <ul class="details"> |
|
9 | <ul class="details"> | |
@@ -14,6 +15,7 | |||||
14 | <div class="wiki"> |
|
15 | <div class="wiki"> | |
15 | <%= textilizable(journal, :notes) unless journal.notes.blank? %> |
|
16 | <%= textilizable(journal, :notes) unless journal.notes.blank? %> | |
16 | </div> |
|
17 | </div> | |
|
18 | </div> | |||
17 | <% end %> |
|
19 | <% end %> | |
18 | </div> |
|
20 | </div> | |
19 | <% end %> |
|
21 | <% end %> |
@@ -47,6 +47,13 module Redmine | |||||
47 | formats.map {|format| [::I18n.t(format.label), format.name] }.sort_by(&:first) |
|
47 | formats.map {|format| [::I18n.t(format.label), format.name] }.sort_by(&:first) | |
48 | end |
|
48 | end | |
49 |
|
49 | |||
|
50 | # Returns an array of formats that can be used for a custom field class | |||
|
51 | def self.formats_for_custom_field_class(klass=nil) | |||
|
52 | all.values.select do |format| | |||
|
53 | format.class.customized_class_names.nil? || format.class.customized_class_names.include?(klass.name) | |||
|
54 | end | |||
|
55 | end | |||
|
56 | ||||
50 | class Base |
|
57 | class Base | |
51 | include Singleton |
|
58 | include Singleton | |
52 | include Redmine::I18n |
|
59 | include Redmine::I18n |
@@ -111,9 +111,8 class AccountControllerOpenidTest < Redmine::ControllerTest | |||||
111 |
|
111 | |||
112 | post :login, :openid_url => 'http://openid.example.com/good_user' |
|
112 | post :login, :openid_url => 'http://openid.example.com/good_user' | |
113 | assert_response :success |
|
113 | assert_response :success | |
114 | assert_template 'register' |
|
114 | ||
115 | assert assigns(:user) |
|
115 | assert_select 'input[name=?][value=?]', 'user[identity_url]', 'http://openid.example.com/good_user' | |
116 | assert_equal 'http://openid.example.com/good_user', assigns(:user)[:identity_url] |
|
|||
117 | end |
|
116 | end | |
118 |
|
117 | |||
119 | def test_login_with_openid_with_new_user_with_missing_information_should_register |
|
118 | def test_login_with_openid_with_new_user_with_missing_information_should_register | |
@@ -121,9 +120,6 class AccountControllerOpenidTest < Redmine::ControllerTest | |||||
121 |
|
120 | |||
122 | post :login, :openid_url => 'http://openid.example.com/good_blank_user' |
|
121 | post :login, :openid_url => 'http://openid.example.com/good_blank_user' | |
123 | assert_response :success |
|
122 | assert_response :success | |
124 | assert_template 'register' |
|
|||
125 | assert assigns(:user) |
|
|||
126 | assert_equal 'http://openid.example.com/good_blank_user', assigns(:user)[:identity_url] |
|
|||
127 |
|
123 | |||
128 | assert_select 'input[name=?]', 'user[login]' |
|
124 | assert_select 'input[name=?]', 'user[login]' | |
129 | assert_select 'input[name=?]', 'user[password]' |
|
125 | assert_select 'input[name=?]', 'user[password]' |
@@ -27,7 +27,6 class AccountControllerTest < Redmine::ControllerTest | |||||
27 | def test_get_login |
|
27 | def test_get_login | |
28 | get :login |
|
28 | get :login | |
29 | assert_response :success |
|
29 | assert_response :success | |
30 | assert_template 'login' |
|
|||
31 |
|
30 | |||
32 | assert_select 'input[name=username]' |
|
31 | assert_select 'input[name=username]' | |
33 | assert_select 'input[name=password]' |
|
32 | assert_select 'input[name=password]' | |
@@ -131,7 +130,6 class AccountControllerTest < Redmine::ControllerTest | |||||
131 | def test_login_with_wrong_password |
|
130 | def test_login_with_wrong_password | |
132 | post :login, :username => 'admin', :password => 'bad' |
|
131 | post :login, :username => 'admin', :password => 'bad' | |
133 | assert_response :success |
|
132 | assert_response :success | |
134 | assert_template 'login' |
|
|||
135 |
|
133 | |||
136 | assert_select 'div.flash.error', :text => /Invalid user or password/ |
|
134 | assert_select 'div.flash.error', :text => /Invalid user or password/ | |
137 | assert_select 'input[name=username][value=admin]' |
|
135 | assert_select 'input[name=username][value=admin]' | |
@@ -190,7 +188,6 class AccountControllerTest < Redmine::ControllerTest | |||||
190 | @request.session[:user_id] = 2 |
|
188 | @request.session[:user_id] = 2 | |
191 | get :logout |
|
189 | get :logout | |
192 | assert_response :success |
|
190 | assert_response :success | |
193 | assert_template 'logout' |
|
|||
194 |
|
191 | |||
195 | assert_equal 2, @request.session[:user_id] |
|
192 | assert_equal 2, @request.session[:user_id] | |
196 | end |
|
193 | end | |
@@ -219,8 +216,6 class AccountControllerTest < Redmine::ControllerTest | |||||
219 | with_settings :self_registration => '3' do |
|
216 | with_settings :self_registration => '3' do | |
220 | get :register |
|
217 | get :register | |
221 | assert_response :success |
|
218 | assert_response :success | |
222 | assert_template 'register' |
|
|||
223 | assert_not_nil assigns(:user) |
|
|||
224 |
|
219 | |||
225 | assert_select 'input[name=?]', 'user[password]' |
|
220 | assert_select 'input[name=?]', 'user[password]' | |
226 | assert_select 'input[name=?]', 'user[password_confirmation]' |
|
221 | assert_select 'input[name=?]', 'user[password_confirmation]' | |
@@ -232,8 +227,7 class AccountControllerTest < Redmine::ControllerTest | |||||
232 | @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' |
|
227 | @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3' | |
233 | get :register |
|
228 | get :register | |
234 | assert_response :success |
|
229 | assert_response :success | |
235 | assert_not_nil assigns(:user) |
|
230 | ||
236 | assert_equal 'fr', assigns(:user).language |
|
|||
237 | assert_select 'select[name=?]', 'user[language]' do |
|
231 | assert_select 'select[name=?]', 'user[language]' do | |
238 | assert_select 'option[value=fr][selected=selected]' |
|
232 | assert_select 'option[value=fr][selected=selected]' | |
239 | end |
|
233 | end | |
@@ -387,7 +381,6 class AccountControllerTest < Redmine::ControllerTest | |||||
387 |
|
381 | |||
388 | get :lost_password, :token => token.value |
|
382 | get :lost_password, :token => token.value | |
389 | assert_response :success |
|
383 | assert_response :success | |
390 | assert_template 'password_recovery' |
|
|||
391 |
|
384 | |||
392 | assert_select 'input[type=hidden][name=token][value=?]', token.value |
|
385 | assert_select 'input[type=hidden][name=token][value=?]', token.value | |
393 | end |
|
386 | end | |
@@ -429,7 +422,6 class AccountControllerTest < Redmine::ControllerTest | |||||
429 |
|
422 | |||
430 | post :lost_password, :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'wrongpass' |
|
423 | post :lost_password, :token => token.value, :new_password => 'newpass', :new_password_confirmation => 'wrongpass' | |
431 | assert_response :success |
|
424 | assert_response :success | |
432 | assert_template 'password_recovery' |
|
|||
433 | assert_not_nil Token.find_by_id(token.id), "Token was deleted" |
|
425 | assert_not_nil Token.find_by_id(token.id), "Token was deleted" | |
434 |
|
426 | |||
435 | assert_select 'input[type=hidden][name=token][value=?]', token.value |
|
427 | assert_select 'input[type=hidden][name=token][value=?]', token.value |
@@ -32,8 +32,6 class ActivitiesControllerTest < Redmine::ControllerTest | |||||
32 | def test_project_index |
|
32 | def test_project_index | |
33 | get :index, :id => 1, :with_subprojects => 0 |
|
33 | get :index, :id => 1, :with_subprojects => 0 | |
34 | assert_response :success |
|
34 | assert_response :success | |
35 | assert_template 'index' |
|
|||
36 | assert_not_nil assigns(:events_by_day) |
|
|||
37 |
|
35 | |||
38 | assert_select 'h3', :text => /#{2.days.ago.to_date.day}/ |
|
36 | assert_select 'h3', :text => /#{2.days.ago.to_date.day}/ | |
39 | assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/ |
|
37 | assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/ | |
@@ -47,8 +45,6 class ActivitiesControllerTest < Redmine::ControllerTest | |||||
47 | def test_previous_project_index |
|
45 | def test_previous_project_index | |
48 | get :index, :id => 1, :from => 2.days.ago.to_date |
|
46 | get :index, :id => 1, :from => 2.days.ago.to_date | |
49 | assert_response :success |
|
47 | assert_response :success | |
50 | assert_template 'index' |
|
|||
51 | assert_not_nil assigns(:events_by_day) |
|
|||
52 |
|
48 | |||
53 | assert_select 'h3', :text => /#{3.days.ago.to_date.day}/ |
|
49 | assert_select 'h3', :text => /#{3.days.ago.to_date.day}/ | |
54 | assert_select 'dl dt.issue a', :text => /Cannot print recipes/ |
|
50 | assert_select 'dl dt.issue a', :text => /Cannot print recipes/ | |
@@ -58,8 +54,6 class ActivitiesControllerTest < Redmine::ControllerTest | |||||
58 | @request.session[:user_id] = 1 |
|
54 | @request.session[:user_id] = 1 | |
59 | get :index |
|
55 | get :index | |
60 | assert_response :success |
|
56 | assert_response :success | |
61 | assert_template 'index' |
|
|||
62 | assert_not_nil assigns(:events_by_day) |
|
|||
63 |
|
57 | |||
64 | i5 = Issue.find(5) |
|
58 | i5 = Issue.find(5) | |
65 | d5 = User.find(1).time_to_date(i5.created_on) |
|
59 | d5 = User.find(1).time_to_date(i5.created_on) | |
@@ -72,8 +66,6 class ActivitiesControllerTest < Redmine::ControllerTest | |||||
72 | @request.session[:user_id] = 1 |
|
66 | @request.session[:user_id] = 1 | |
73 | get :index, :user_id => 2 |
|
67 | get :index, :user_id => 2 | |
74 | assert_response :success |
|
68 | assert_response :success | |
75 | assert_template 'index' |
|
|||
76 | assert_not_nil assigns(:events_by_day) |
|
|||
77 |
|
69 | |||
78 | assert_select 'h2 a[href="/users/2"]', :text => 'John Smith' |
|
70 | assert_select 'h2 a[href="/users/2"]', :text => 'John Smith' | |
79 |
|
71 | |||
@@ -92,7 +84,6 class ActivitiesControllerTest < Redmine::ControllerTest | |||||
92 | def test_index_atom_feed |
|
84 | def test_index_atom_feed | |
93 | get :index, :format => 'atom', :with_subprojects => 0 |
|
85 | get :index, :format => 'atom', :with_subprojects => 0 | |
94 | assert_response :success |
|
86 | assert_response :success | |
95 | assert_template 'common/feed' |
|
|||
96 |
|
87 | |||
97 | assert_select 'feed' do |
|
88 | assert_select 'feed' do | |
98 | assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0' |
|
89 | assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0' | |
@@ -115,7 +106,6 class ActivitiesControllerTest < Redmine::ControllerTest | |||||
115 | :show_wiki_edits => 1 |
|
106 | :show_wiki_edits => 1 | |
116 |
|
107 | |||
117 | assert_response :success |
|
108 | assert_response :success | |
118 | assert_template 'common/feed' |
|
|||
119 |
|
109 | |||
120 | assert_select 'feed' do |
|
110 | assert_select 'feed' do | |
121 | assert_select 'link[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' |
|
111 | assert_select 'link[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' | |
@@ -130,7 +120,6 class ActivitiesControllerTest < Redmine::ControllerTest | |||||
130 | with_settings :default_language => 'en' do |
|
120 | with_settings :default_language => 'en' do | |
131 | get :index, :format => 'atom', :show_issues => '1' |
|
121 | get :index, :format => 'atom', :show_issues => '1' | |
132 | assert_response :success |
|
122 | assert_response :success | |
133 | assert_template 'common/feed' |
|
|||
134 |
|
123 | |||
135 | assert_select 'title', :text => /Issues/ |
|
124 | assert_select 'title', :text => /Issues/ | |
136 | end |
|
125 | end | |
@@ -140,22 +129,21 class ActivitiesControllerTest < Redmine::ControllerTest | |||||
140 | get :index, :user_id => 2, :format => 'atom' |
|
129 | get :index, :user_id => 2, :format => 'atom' | |
141 |
|
130 | |||
142 | assert_response :success |
|
131 | assert_response :success | |
143 | assert_template 'common/feed' |
|
|||
144 | assert_select 'title', :text => "Redmine: #{User.find(2).name}" |
|
132 | assert_select 'title', :text => "Redmine: #{User.find(2).name}" | |
145 | end |
|
133 | end | |
146 |
|
134 | |||
147 | def test_index_should_show_private_notes_with_permission_only |
|
135 | def test_index_should_show_private_notes_with_permission_only | |
148 |
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes |
|
136 | journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes', :private_notes => true) | |
149 | @request.session[:user_id] = 2 |
|
137 | @request.session[:user_id] = 2 | |
150 |
|
138 | |||
151 | get :index |
|
139 | get :index | |
152 | assert_response :success |
|
140 | assert_response :success | |
153 | assert_include journal, assigns(:events_by_day).values.flatten |
|
141 | assert_select 'dl', :text => /Private notes/ | |
154 |
|
142 | |||
155 | Role.find(1).remove_permission! :view_private_notes |
|
143 | Role.find(1).remove_permission! :view_private_notes | |
156 | get :index |
|
144 | get :index | |
157 | assert_response :success |
|
145 | assert_response :success | |
158 | assert_not_include journal, assigns(:events_by_day).values.flatten |
|
146 | assert_select 'dl', :text => /Private notes/, :count => 0 | |
159 | end |
|
147 | end | |
160 |
|
148 | |||
161 | def test_index_with_submitted_scope_should_save_as_preference |
|
149 | def test_index_with_submitted_scope_should_save_as_preference | |
@@ -174,6 +162,11 class ActivitiesControllerTest < Redmine::ControllerTest | |||||
174 |
|
162 | |||
175 | get :index |
|
163 | get :index | |
176 | assert_response :success |
|
164 | assert_response :success | |
177 | assert_equal %w(issues news), assigns(:activity).scope |
|
165 | ||
|
166 | assert_select '#activity_scope_form' do | |||
|
167 | assert_select 'input[checked=checked]', 2 | |||
|
168 | assert_select 'input[name=show_issues][checked=checked]' | |||
|
169 | assert_select 'input[name=show_news][checked=checked]' | |||
|
170 | end | |||
178 | end |
|
171 | end | |
179 | end |
|
172 | end |
@@ -39,29 +39,21 class AdminControllerTest < Redmine::ControllerTest | |||||
39 | def test_projects |
|
39 | def test_projects | |
40 | get :projects |
|
40 | get :projects | |
41 | assert_response :success |
|
41 | assert_response :success | |
42 |
assert_ |
|
42 | assert_select 'tr.project.closed', 0 | |
43 | assert_not_nil assigns(:projects) |
|
|||
44 | # active projects only |
|
|||
45 | assert_nil assigns(:projects).detect {|u| !u.active?} |
|
|||
46 | end |
|
43 | end | |
47 |
|
44 | |||
48 | def test_projects_with_status_filter |
|
45 | def test_projects_with_status_filter | |
49 | get :projects, :status => 1 |
|
46 | get :projects, :status => 1 | |
50 | assert_response :success |
|
47 | assert_response :success | |
51 |
assert_ |
|
48 | assert_select 'tr.project.closed', 0 | |
52 | assert_not_nil assigns(:projects) |
|
|||
53 | # active projects only |
|
|||
54 | assert_nil assigns(:projects).detect {|u| !u.active?} |
|
|||
55 | end |
|
49 | end | |
56 |
|
50 | |||
57 | def test_projects_with_name_filter |
|
51 | def test_projects_with_name_filter | |
58 | get :projects, :name => 'store', :status => '' |
|
52 | get :projects, :name => 'store', :status => '' | |
59 | assert_response :success |
|
53 | assert_response :success | |
60 | assert_template 'projects' |
|
54 | ||
61 | projects = assigns(:projects) |
|
55 | assert_select 'tr.project td.name', :text => 'OnlineStore' | |
62 |
assert_ |
|
56 | assert_select 'tr.project', 1 | |
63 | assert_equal 1, projects.size |
|
|||
64 | assert_equal 'OnlineStore', projects.first.name |
|
|||
65 | end |
|
57 | end | |
66 |
|
58 | |||
67 | def test_load_default_configuration_data |
|
59 | def test_load_default_configuration_data | |
@@ -107,8 +99,7 class AdminControllerTest < Redmine::ControllerTest | |||||
107 |
|
99 | |||
108 | get :plugins |
|
100 | get :plugins | |
109 | assert_response :success |
|
101 | assert_response :success | |
110 | assert_template 'plugins' |
|
102 | assert_select '.nodata' | |
111 | assert_equal [], assigns(:plugins) |
|
|||
112 | end |
|
103 | end | |
113 |
|
104 | |||
114 | def test_plugins |
|
105 | def test_plugins | |
@@ -125,7 +116,6 class AdminControllerTest < Redmine::ControllerTest | |||||
125 |
|
116 | |||
126 | get :plugins |
|
117 | get :plugins | |
127 | assert_response :success |
|
118 | assert_response :success | |
128 | assert_template 'plugins' |
|
|||
129 |
|
119 | |||
130 | assert_select 'tr#plugin-foo' do |
|
120 | assert_select 'tr#plugin-foo' do | |
131 | assert_select 'td span.name', :text => 'Foo plugin' |
|
121 | assert_select 'td span.name', :text => 'Foo plugin' | |
@@ -140,7 +130,6 class AdminControllerTest < Redmine::ControllerTest | |||||
140 | def test_info |
|
130 | def test_info | |
141 | get :info |
|
131 | get :info | |
142 | assert_response :success |
|
132 | assert_response :success | |
143 | assert_template 'info' |
|
|||
144 | end |
|
133 | end | |
145 |
|
134 | |||
146 | def test_admin_menu_plugin_extension |
|
135 | def test_admin_menu_plugin_extension |
@@ -38,7 +38,7 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
38 | # 060719210727_changeset_utf8.diff |
|
38 | # 060719210727_changeset_utf8.diff | |
39 | get :show, :id => 14, :type => dt |
|
39 | get :show, :id => 14, :type => dt | |
40 | assert_response :success |
|
40 | assert_response :success | |
41 | assert_template 'diff' |
|
41 | ||
42 | assert_equal 'text/html', @response.content_type |
|
42 | assert_equal 'text/html', @response.content_type | |
43 | assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/ |
|
43 | assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/ | |
44 | assert_select 'td.line-code', :text => /Demande créée avec succès/ |
|
44 | assert_select 'td.line-code', :text => /Demande créée avec succès/ | |
@@ -52,7 +52,7 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
52 | # 060719210727_changeset_iso8859-1.diff |
|
52 | # 060719210727_changeset_iso8859-1.diff | |
53 | get :show, :id => 5, :type => dt |
|
53 | get :show, :id => 5, :type => dt | |
54 | assert_response :success |
|
54 | assert_response :success | |
55 | assert_template 'diff' |
|
55 | ||
56 | assert_equal 'text/html', @response.content_type |
|
56 | assert_equal 'text/html', @response.content_type | |
57 | assert_select 'th.filename', :text => /issues_controller.rb\t\(r\?vision 1484\)/ |
|
57 | assert_select 'th.filename', :text => /issues_controller.rb\t\(r\?vision 1484\)/ | |
58 | assert_select 'td.line-code', :text => /Demande cr\?\?e avec succ\?s/ |
|
58 | assert_select 'td.line-code', :text => /Demande cr\?\?e avec succ\?s/ | |
@@ -67,7 +67,7 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
67 | # 060719210727_changeset_iso8859-1.diff |
|
67 | # 060719210727_changeset_iso8859-1.diff | |
68 | get :show, :id => 5, :type => dt |
|
68 | get :show, :id => 5, :type => dt | |
69 | assert_response :success |
|
69 | assert_response :success | |
70 | assert_template 'diff' |
|
70 | ||
71 | assert_equal 'text/html', @response.content_type |
|
71 | assert_equal 'text/html', @response.content_type | |
72 | assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/ |
|
72 | assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/ | |
73 | assert_select 'td.line-code', :text => /Demande créée avec succès/ |
|
73 | assert_select 'td.line-code', :text => /Demande créée avec succès/ | |
@@ -82,16 +82,15 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
82 | user1.preference.save |
|
82 | user1.preference.save | |
83 | user = User.find(1) |
|
83 | user = User.find(1) | |
84 | assert_nil user.pref[:diff_type] |
|
84 | assert_nil user.pref[:diff_type] | |
85 |
|
||||
86 | @request.session[:user_id] = 1 # admin |
|
85 | @request.session[:user_id] = 1 # admin | |
|
86 | ||||
87 | get :show, :id => 5 |
|
87 | get :show, :id => 5 | |
88 | assert_response :success |
|
88 | assert_response :success | |
89 | assert_template 'diff' |
|
|||
90 | user.reload |
|
89 | user.reload | |
91 | assert_equal "inline", user.pref[:diff_type] |
|
90 | assert_equal "inline", user.pref[:diff_type] | |
|
91 | ||||
92 | get :show, :id => 5, :type => 'sbs' |
|
92 | get :show, :id => 5, :type => 'sbs' | |
93 | assert_response :success |
|
93 | assert_response :success | |
94 | assert_template 'diff' |
|
|||
95 | user.reload |
|
94 | user.reload | |
96 | assert_equal "sbs", user.pref[:diff_type] |
|
95 | assert_equal "sbs", user.pref[:diff_type] | |
97 | end |
|
96 | end | |
@@ -106,7 +105,6 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
106 |
|
105 | |||
107 | get :show, :id => a.id, :type => 'inline' |
|
106 | get :show, :id => a.id, :type => 'inline' | |
108 | assert_response :success |
|
107 | assert_response :success | |
109 | assert_template 'diff' |
|
|||
110 | assert_equal 'text/html', @response.content_type |
|
108 | assert_equal 'text/html', @response.content_type | |
111 | assert_select 'th.filename', :text => 'test1.txt' |
|
109 | assert_select 'th.filename', :text => 'test1.txt' | |
112 | end |
|
110 | end | |
@@ -114,7 +112,6 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
114 | def test_show_text_file |
|
112 | def test_show_text_file | |
115 | get :show, :id => 4 |
|
113 | get :show, :id => 4 | |
116 | assert_response :success |
|
114 | assert_response :success | |
117 | assert_template 'file' |
|
|||
118 | assert_equal 'text/html', @response.content_type |
|
115 | assert_equal 'text/html', @response.content_type | |
119 | set_tmp_attachments_directory |
|
116 | set_tmp_attachments_directory | |
120 | end |
|
117 | end | |
@@ -131,7 +128,6 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
131 |
|
128 | |||
132 | get :show, :id => a.id |
|
129 | get :show, :id => a.id | |
133 | assert_response :success |
|
130 | assert_response :success | |
134 | assert_template 'file' |
|
|||
135 | assert_equal 'text/html', @response.content_type |
|
131 | assert_equal 'text/html', @response.content_type | |
136 | assert_select 'tr#L1' do |
|
132 | assert_select 'tr#L1' do | |
137 | assert_select 'th.line-num', :text => '1' |
|
133 | assert_select 'th.line-num', :text => '1' | |
@@ -150,7 +146,6 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
150 |
|
146 | |||
151 | get :show, :id => a.id |
|
147 | get :show, :id => a.id | |
152 | assert_response :success |
|
148 | assert_response :success | |
153 | assert_template 'file' |
|
|||
154 | assert_equal 'text/html', @response.content_type |
|
149 | assert_equal 'text/html', @response.content_type | |
155 | assert_select 'tr#L7' do |
|
150 | assert_select 'tr#L7' do | |
156 | assert_select 'th.line-num', :text => '7' |
|
151 | assert_select 'th.line-num', :text => '7' | |
@@ -170,7 +165,6 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
170 |
|
165 | |||
171 | get :show, :id => a.id |
|
166 | get :show, :id => a.id | |
172 | assert_response :success |
|
167 | assert_response :success | |
173 | assert_template 'file' |
|
|||
174 | assert_equal 'text/html', @response.content_type |
|
168 | assert_equal 'text/html', @response.content_type | |
175 | assert_select 'tr#L7' do |
|
169 | assert_select 'tr#L7' do | |
176 | assert_select 'th.line-num', :text => '7' |
|
170 | assert_select 'th.line-num', :text => '7' | |
@@ -180,12 +174,13 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
180 | end |
|
174 | end | |
181 |
|
175 | |||
182 | def test_show_text_file_should_show_other_if_too_big |
|
176 | def test_show_text_file_should_show_other_if_too_big | |
|
177 | @request.session[:user_id] = 2 | |||
183 | with_settings :file_max_size_displayed => 512 do |
|
178 | with_settings :file_max_size_displayed => 512 do | |
184 | Attachment.find(4).update_attribute :filesize, 754.kilobyte |
|
179 | Attachment.find(4).update_attribute :filesize, 754.kilobyte | |
185 | get :show, :id => 4 |
|
180 | get :show, :id => 4 | |
186 | assert_response :success |
|
181 | assert_response :success | |
187 | assert_template 'other' |
|
|||
188 | assert_equal 'text/html', @response.content_type |
|
182 | assert_equal 'text/html', @response.content_type | |
|
183 | assert_select '.nodata', :text => 'No preview available' | |||
189 | end |
|
184 | end | |
190 | set_tmp_attachments_directory |
|
185 | set_tmp_attachments_directory | |
191 | end |
|
186 | end | |
@@ -194,14 +189,13 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
194 | @request.session[:user_id] = 2 |
|
189 | @request.session[:user_id] = 2 | |
195 | get :show, :id => 16 |
|
190 | get :show, :id => 16 | |
196 | assert_response :success |
|
191 | assert_response :success | |
197 | assert_template 'image' |
|
|||
198 | assert_equal 'text/html', @response.content_type |
|
192 | assert_equal 'text/html', @response.content_type | |
199 | assert_select 'img.filecontent', :src => attachments(:attachments_010).filename |
|
193 | assert_select 'img.filecontent', :src => attachments(:attachments_010).filename | |
200 | end |
|
194 | end | |
201 |
|
195 | |||
202 | def test_show_other |
|
196 | def test_show_other | |
|
197 | @request.session[:user_id] = 2 | |||
203 | get :show, :id => 6 |
|
198 | get :show, :id => 6 | |
204 | assert_template 'other' |
|
|||
205 | assert_equal 'text/html', @response.content_type |
|
199 | assert_equal 'text/html', @response.content_type | |
206 | assert_select '.nodata', :text => 'No preview available' |
|
200 | assert_select '.nodata', :text => 'No preview available' | |
207 | set_tmp_attachments_directory |
|
201 | set_tmp_attachments_directory | |
@@ -351,13 +345,12 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
351 | @request.session[:user_id] = 2 |
|
345 | @request.session[:user_id] = 2 | |
352 | get :edit, :object_type => 'issues', :object_id => '2' |
|
346 | get :edit, :object_type => 'issues', :object_id => '2' | |
353 | assert_response :success |
|
347 | assert_response :success | |
354 | assert_template 'edit' |
|
|||
355 |
|
||||
356 | container = Issue.find(2) |
|
|||
357 | assert_equal container, assigns(:container) |
|
|||
358 | assert_equal container.attachments.size, assigns(:attachments).size |
|
|||
359 |
|
348 | |||
360 | assert_select 'form[action=?]', '/attachments/issues/2' do |
|
349 | assert_select 'form[action=?]', '/attachments/issues/2' do | |
|
350 | Issue.find(2).attachments.each do |attachment| | |||
|
351 | assert_select "tr#attachment-#{attachment.id}" | |||
|
352 | end | |||
|
353 | ||||
361 | assert_select 'tr#attachment-4' do |
|
354 | assert_select 'tr#attachment-4' do | |
362 | assert_select 'input[name=?][value=?]', 'attachments[4][filename]', 'source.rb' |
|
355 | assert_select 'input[name=?][value=?]', 'attachments[4][filename]', 'source.rb' | |
363 | assert_select 'input[name=?][value=?]', 'attachments[4][description]', 'This is a Ruby source file' |
|
356 | assert_select 'input[name=?][value=?]', 'attachments[4][description]', 'This is a Ruby source file' | |
@@ -401,7 +394,6 class AttachmentsControllerTest < Redmine::ControllerTest | |||||
401 | } |
|
394 | } | |
402 |
|
395 | |||
403 | assert_response :success |
|
396 | assert_response :success | |
404 | assert_template 'edit' |
|
|||
405 | assert_select_error /file cannot be blank/i |
|
397 | assert_select_error /file cannot be blank/i | |
406 |
|
398 | |||
407 | # The other attachment should not be updated |
|
399 | # The other attachment should not be updated |
@@ -26,21 +26,12 class AuthSourcesControllerTest < Redmine::ControllerTest | |||||
26 |
|
26 | |||
27 | def test_index |
|
27 | def test_index | |
28 | get :index |
|
28 | get :index | |
29 |
|
||||
30 | assert_response :success |
|
29 | assert_response :success | |
31 | assert_template 'index' |
|
|||
32 | assert_not_nil assigns(:auth_sources) |
|
|||
33 | end |
|
30 | end | |
34 |
|
31 | |||
35 | def test_new |
|
32 | def test_new | |
36 | get :new |
|
33 | get :new | |
37 |
|
||||
38 | assert_response :success |
|
34 | assert_response :success | |
39 | assert_template 'new' |
|
|||
40 |
|
||||
41 | source = assigns(:auth_source) |
|
|||
42 | assert_equal AuthSourceLdap, source.class |
|
|||
43 | assert source.new_record? |
|
|||
44 |
|
35 | |||
45 | assert_select 'form#auth_source_form' do |
|
36 | assert_select 'form#auth_source_form' do | |
46 | assert_select 'input[name=type][value=AuthSourceLdap]' |
|
37 | assert_select 'input[name=type][value=AuthSourceLdap]' | |
@@ -72,16 +63,13 class AuthSourcesControllerTest < Redmine::ControllerTest | |||||
72 | :auth_source => {:name => 'Test', :host => '', |
|
63 | :auth_source => {:name => 'Test', :host => '', | |
73 | :port => '389', :attr_login => 'cn'} |
|
64 | :port => '389', :attr_login => 'cn'} | |
74 | assert_response :success |
|
65 | assert_response :success | |
75 | assert_template 'new' |
|
|||
76 | end |
|
66 | end | |
77 | assert_select_error /host cannot be blank/i |
|
67 | assert_select_error /host cannot be blank/i | |
78 | end |
|
68 | end | |
79 |
|
69 | |||
80 | def test_edit |
|
70 | def test_edit | |
81 | get :edit, :id => 1 |
|
71 | get :edit, :id => 1 | |
82 |
|
||||
83 | assert_response :success |
|
72 | assert_response :success | |
84 | assert_template 'edit' |
|
|||
85 |
|
73 | |||
86 | assert_select 'form#auth_source_form' do |
|
74 | assert_select 'form#auth_source_form' do | |
87 | assert_select 'input[name=?]', 'auth_source[host]' |
|
75 | assert_select 'input[name=?]', 'auth_source[host]' | |
@@ -117,7 +105,6 class AuthSourcesControllerTest < Redmine::ControllerTest | |||||
117 | :auth_source => {:name => 'Renamed', :host => '', |
|
105 | :auth_source => {:name => 'Renamed', :host => '', | |
118 | :port => '389', :attr_login => 'uid'} |
|
106 | :port => '389', :attr_login => 'uid'} | |
119 | assert_response :success |
|
107 | assert_response :success | |
120 | assert_template 'edit' |
|
|||
121 | assert_select_error /host cannot be blank/i |
|
108 | assert_select_error /host cannot be blank/i | |
122 | end |
|
109 | end | |
123 |
|
110 |
@@ -31,49 +31,43 class AutoCompletesControllerTest < Redmine::ControllerTest | |||||
31 | def test_issues_should_not_be_case_sensitive |
|
31 | def test_issues_should_not_be_case_sensitive | |
32 | get :issues, :project_id => 'ecookbook', :q => 'ReCiPe' |
|
32 | get :issues, :project_id => 'ecookbook', :q => 'ReCiPe' | |
33 | assert_response :success |
|
33 | assert_response :success | |
34 | assert_not_nil assigns(:issues) |
|
34 | assert_include "recipe", response.body | |
35 | assert assigns(:issues).detect {|issue| issue.subject.match /recipe/} |
|
|||
36 | end |
|
35 | end | |
37 |
|
36 | |||
38 | def test_issues_should_accept_term_param |
|
37 | def test_issues_should_accept_term_param | |
39 | get :issues, :project_id => 'ecookbook', :term => 'ReCiPe' |
|
38 | get :issues, :project_id => 'ecookbook', :term => 'ReCiPe' | |
40 | assert_response :success |
|
39 | assert_response :success | |
41 | assert_not_nil assigns(:issues) |
|
40 | assert_include "recipe", response.body | |
42 | assert assigns(:issues).detect {|issue| issue.subject.match /recipe/} |
|
|||
43 | end |
|
41 | end | |
44 |
|
42 | |||
45 | def test_issues_should_return_issue_with_given_id |
|
43 | def test_issues_should_return_issue_with_given_id | |
46 | get :issues, :project_id => 'subproject1', :q => '13' |
|
44 | get :issues, :project_id => 'subproject1', :q => '13' | |
47 | assert_response :success |
|
45 | assert_response :success | |
48 | assert_not_nil assigns(:issues) |
|
46 | assert_include "Bug #13", response.body | |
49 | assert assigns(:issues).include?(Issue.find(13)) |
|
|||
50 | end |
|
47 | end | |
51 |
|
48 | |||
52 | def test_issues_should_return_issue_with_given_id_preceded_with_hash |
|
49 | def test_issues_should_return_issue_with_given_id_preceded_with_hash | |
53 | get :issues, :project_id => 'subproject1', :q => '#13' |
|
50 | get :issues, :project_id => 'subproject1', :q => '#13' | |
54 | assert_response :success |
|
51 | assert_response :success | |
55 | assert_not_nil assigns(:issues) |
|
52 | assert_include "Bug #13", response.body | |
56 | assert assigns(:issues).include?(Issue.find(13)) |
|
|||
57 | end |
|
53 | end | |
58 |
|
54 | |||
59 | def test_auto_complete_with_scope_all_should_search_other_projects |
|
55 | def test_auto_complete_with_scope_all_should_search_other_projects | |
60 | get :issues, :project_id => 'ecookbook', :q => '13', :scope => 'all' |
|
56 | get :issues, :project_id => 'ecookbook', :q => '13', :scope => 'all' | |
61 | assert_response :success |
|
57 | assert_response :success | |
62 | assert_not_nil assigns(:issues) |
|
58 | assert_include "Bug #13", response.body | |
63 | assert assigns(:issues).include?(Issue.find(13)) |
|
|||
64 | end |
|
59 | end | |
65 |
|
60 | |||
66 | def test_auto_complete_without_project_should_search_all_projects |
|
61 | def test_auto_complete_without_project_should_search_all_projects | |
67 | get :issues, :q => '13' |
|
62 | get :issues, :q => '13' | |
68 | assert_response :success |
|
63 | assert_response :success | |
69 | assert_not_nil assigns(:issues) |
|
64 | assert_include "Bug #13", response.body | |
70 | assert assigns(:issues).include?(Issue.find(13)) |
|
|||
71 | end |
|
65 | end | |
72 |
|
66 | |||
73 | def test_auto_complete_without_scope_all_should_not_search_other_projects |
|
67 | def test_auto_complete_without_scope_all_should_not_search_other_projects | |
74 | get :issues, :project_id => 'ecookbook', :q => '13' |
|
68 | get :issues, :project_id => 'ecookbook', :q => '13' | |
75 | assert_response :success |
|
69 | assert_response :success | |
76 | assert_equal [], assigns(:issues) |
|
70 | assert_not_include "Bug #13", response.body | |
77 | end |
|
71 | end | |
78 |
|
72 | |||
79 | def test_issues_should_return_json |
|
73 | def test_issues_should_return_json |
@@ -27,9 +27,7 class BoardsControllerTest < Redmine::ControllerTest | |||||
27 | def test_index |
|
27 | def test_index | |
28 | get :index, :project_id => 1 |
|
28 | get :index, :project_id => 1 | |
29 | assert_response :success |
|
29 | assert_response :success | |
30 | assert_template 'index' |
|
30 | assert_select 'table.boards' | |
31 | assert_not_nil assigns(:boards) |
|
|||
32 | assert_not_nil assigns(:project) |
|
|||
33 | end |
|
31 | end | |
34 |
|
32 | |||
35 | def test_index_not_found |
|
33 | def test_index_not_found | |
@@ -42,17 +40,18 class BoardsControllerTest < Redmine::ControllerTest | |||||
42 |
|
40 | |||
43 | get :index, :project_id => 1 |
|
41 | get :index, :project_id => 1 | |
44 | assert_response :success |
|
42 | assert_response :success | |
45 | assert_template 'show' |
|
43 | ||
46 | assert_not_nil assigns(:topics) |
|
44 | assert_select 'table.boards', 0 | |
|
45 | assert_select 'table.messages' | |||
47 | end |
|
46 | end | |
48 |
|
47 | |||
49 | def test_show |
|
48 | def test_show | |
50 | get :show, :project_id => 1, :id => 1 |
|
49 | get :show, :project_id => 1, :id => 1 | |
51 | assert_response :success |
|
50 | assert_response :success | |
52 | assert_template 'show' |
|
51 | ||
53 | assert_not_nil assigns(:board) |
|
52 | assert_select 'table.messages tbody' do | |
54 | assert_not_nil assigns(:project) |
|
53 | assert_select 'tr', Board.find(1).topics.count | |
55 | assert_not_nil assigns(:topics) |
|
54 | end | |
56 | end |
|
55 | end | |
57 |
|
56 | |||
58 | def test_show_should_display_sticky_messages_first |
|
57 | def test_show_should_display_sticky_messages_first | |
@@ -62,11 +61,12 class BoardsControllerTest < Redmine::ControllerTest | |||||
62 | get :show, :project_id => 1, :id => 1 |
|
61 | get :show, :project_id => 1, :id => 1 | |
63 | assert_response :success |
|
62 | assert_response :success | |
64 |
|
63 | |||
65 | topics = assigns(:topics) |
|
64 | assert_select 'table.messages tbody' do | |
66 | assert_not_nil topics |
|
65 | # row is here... | |
67 | assert topics.size > 1, "topics size was #{topics.size}" |
|
66 | assert_select 'tr.sticky' | |
68 | assert topics.first.sticky? |
|
67 | # ...and in first position | |
69 | assert topics.first.updated_on < topics.second.updated_on |
|
68 | assert_select 'tr.sticky:first-child' | |
|
69 | end | |||
70 | end |
|
70 | end | |
71 |
|
71 | |||
72 | def test_show_should_display_message_with_last_reply_first |
|
72 | def test_show_should_display_message_with_last_reply_first | |
@@ -79,16 +79,17 class BoardsControllerTest < Redmine::ControllerTest | |||||
79 |
|
79 | |||
80 | get :show, :project_id => 1, :id => 1 |
|
80 | get :show, :project_id => 1, :id => 1 | |
81 | assert_response :success |
|
81 | assert_response :success | |
82 | topics = assigns(:topics) |
|
82 | ||
83 | assert_not_nil topics |
|
83 | assert_select 'table.messages tbody' do | |
84 | assert_equal old_topic, topics.first |
|
84 | assert_select "tr#message-#{old_topic.id}" | |
|
85 | assert_select "tr#message-#{old_topic.id}:first-child" | |||
|
86 | end | |||
85 | end |
|
87 | end | |
86 |
|
88 | |||
87 | def test_show_with_permission_should_display_the_new_message_form |
|
89 | def test_show_with_permission_should_display_the_new_message_form | |
88 | @request.session[:user_id] = 2 |
|
90 | @request.session[:user_id] = 2 | |
89 | get :show, :project_id => 1, :id => 1 |
|
91 | get :show, :project_id => 1, :id => 1 | |
90 | assert_response :success |
|
92 | assert_response :success | |
91 | assert_template 'show' |
|
|||
92 |
|
93 | |||
93 | assert_select 'form#message-form' do |
|
94 | assert_select 'form#message-form' do | |
94 | assert_select 'input[name=?]', 'message[subject]' |
|
95 | assert_select 'input[name=?]', 'message[subject]' | |
@@ -98,10 +99,8 class BoardsControllerTest < Redmine::ControllerTest | |||||
98 | def test_show_atom |
|
99 | def test_show_atom | |
99 | get :show, :project_id => 1, :id => 1, :format => 'atom' |
|
100 | get :show, :project_id => 1, :id => 1, :format => 'atom' | |
100 | assert_response :success |
|
101 | assert_response :success | |
101 | assert_template 'common/feed' |
|
102 | ||
102 | assert_not_nil assigns(:board) |
|
103 | assert_select 'feed > entry > title', :text => 'Help: RE: post 2' | |
103 | assert_not_nil assigns(:project) |
|
|||
104 | assert_not_nil assigns(:messages) |
|
|||
105 | end |
|
104 | end | |
106 |
|
105 | |||
107 | def test_show_not_found |
|
106 | def test_show_not_found | |
@@ -113,7 +112,6 class BoardsControllerTest < Redmine::ControllerTest | |||||
113 | @request.session[:user_id] = 2 |
|
112 | @request.session[:user_id] = 2 | |
114 | get :new, :project_id => 1 |
|
113 | get :new, :project_id => 1 | |
115 | assert_response :success |
|
114 | assert_response :success | |
116 | assert_template 'new' |
|
|||
117 |
|
115 | |||
118 | assert_select 'select[name=?]', 'board[parent_id]' do |
|
116 | assert_select 'select[name=?]', 'board[parent_id]' do | |
119 | assert_select 'option', (Project.find(1).boards.size + 1) |
|
117 | assert_select 'option', (Project.find(1).boards.size + 1) | |
@@ -132,7 +130,6 class BoardsControllerTest < Redmine::ControllerTest | |||||
132 |
|
130 | |||
133 | get :new, :project_id => 1 |
|
131 | get :new, :project_id => 1 | |
134 | assert_response :success |
|
132 | assert_response :success | |
135 | assert_template 'new' |
|
|||
136 |
|
133 | |||
137 | assert_select 'select[name=?]', 'board[parent_id]', 0 |
|
134 | assert_select 'select[name=?]', 'board[parent_id]', 0 | |
138 | end |
|
135 | end |
@@ -34,22 +34,19 class CalendarsControllerTest < Redmine::ControllerTest | |||||
34 | def test_show |
|
34 | def test_show | |
35 | get :show, :project_id => 1 |
|
35 | get :show, :project_id => 1 | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 | assert_template :partial => '_calendar' |
|
|||
38 | assert_not_nil assigns(:calendar) |
|
|||
39 | end |
|
37 | end | |
40 |
|
38 | |||
41 | def test_show_should_run_custom_queries |
|
39 | def test_show_should_run_custom_queries | |
42 | @query = IssueQuery.create!(:name => 'Calendar', :visibility => IssueQuery::VISIBILITY_PUBLIC) |
|
40 | @query = IssueQuery.create!(:name => 'Calendar Query', :visibility => IssueQuery::VISIBILITY_PUBLIC) | |
43 |
|
41 | |||
44 | get :show, :query_id => @query.id |
|
42 | get :show, :query_id => @query.id | |
45 | assert_response :success |
|
43 | assert_response :success | |
|
44 | assert_select 'h2', :text => 'Calendar Query' | |||
46 | end |
|
45 | end | |
47 |
|
46 | |||
48 | def test_cross_project_calendar |
|
47 | def test_cross_project_calendar | |
49 | get :show |
|
48 | get :show | |
50 | assert_response :success |
|
49 | assert_response :success | |
51 | assert_template :partial => '_calendar' |
|
|||
52 | assert_not_nil assigns(:calendar) |
|
|||
53 | end |
|
50 | end | |
54 |
|
51 | |||
55 | def test_week_number_calculation |
|
52 | def test_week_number_calculation |
@@ -37,7 +37,6 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
37 | @request.session[:user_id] = 2 |
|
37 | @request.session[:user_id] = 2 | |
38 | get :issues, :ids => [1] |
|
38 | get :issues, :ids => [1] | |
39 | assert_response :success |
|
39 | assert_response :success | |
40 | assert_template 'context_menus/issues' |
|
|||
41 |
|
40 | |||
42 | assert_select 'a.icon-edit[href=?]', '/issues/1/edit', :text => 'Edit' |
|
41 | assert_select 'a.icon-edit[href=?]', '/issues/1/edit', :text => 'Edit' | |
43 | assert_select 'a.icon-copy[href=?]', '/projects/ecookbook/issues/1/copy', :text => 'Copy' |
|
42 | assert_select 'a.icon-copy[href=?]', '/projects/ecookbook/issues/1/copy', :text => 'Copy' | |
@@ -59,7 +58,7 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
59 | with_settings :default_language => 'en' do |
|
58 | with_settings :default_language => 'en' do | |
60 | get :issues, :ids => [1] |
|
59 | get :issues, :ids => [1] | |
61 | assert_response :success |
|
60 | assert_response :success | |
62 | assert_template 'context_menus/issues' |
|
61 | ||
63 | assert_select 'a.icon-del.disabled[href="#"]', :text => 'Delete' |
|
62 | assert_select 'a.icon-del.disabled[href="#"]', :text => 'Delete' | |
64 | end |
|
63 | end | |
65 | end |
|
64 | end | |
@@ -68,11 +67,8 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
68 | @request.session[:user_id] = 2 |
|
67 | @request.session[:user_id] = 2 | |
69 | get :issues, :ids => [1, 2] |
|
68 | get :issues, :ids => [1, 2] | |
70 | assert_response :success |
|
69 | assert_response :success | |
71 | assert_template 'context_menus/issues' |
|
|||
72 | assert_not_nil assigns(:issues) |
|
|||
73 | assert_equal [1, 2], assigns(:issues).map(&:id).sort |
|
|||
74 |
|
70 | |||
75 |
ids = |
|
71 | ids = [1, 2].map {|i| "ids%5B%5D=#{i}"}.join('&') | |
76 |
|
72 | |||
77 | assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit' |
|
73 | assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit' | |
78 | assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy' |
|
74 | assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy' | |
@@ -87,11 +83,8 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
87 | @request.session[:user_id] = 2 |
|
83 | @request.session[:user_id] = 2 | |
88 | get :issues, :ids => [1, 2, 6] |
|
84 | get :issues, :ids => [1, 2, 6] | |
89 | assert_response :success |
|
85 | assert_response :success | |
90 | assert_template 'context_menus/issues' |
|
|||
91 | assert_not_nil assigns(:issues) |
|
|||
92 | assert_equal [1, 2, 6], assigns(:issues).map(&:id).sort |
|
|||
93 |
|
86 | |||
94 |
ids = |
|
87 | ids = [1, 2, 6].map {|i| "ids%5B%5D=#{i}"}.join('&') | |
95 |
|
88 | |||
96 | assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit' |
|
89 | assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit' | |
97 | assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete' |
|
90 | assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete' | |
@@ -214,7 +207,6 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
214 | @request.session[:user_id] = 2 |
|
207 | @request.session[:user_id] = 2 | |
215 | get :issues, :ids => [1] |
|
208 | get :issues, :ids => [1] | |
216 | assert_response :success |
|
209 | assert_response :success | |
217 | assert_template 'context_menus/issues' |
|
|||
218 |
|
210 | |||
219 | assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me / |
|
211 | assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me / | |
220 | end |
|
212 | end | |
@@ -225,9 +217,7 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
225 |
|
217 | |||
226 | get :issues, :ids => [1, 4] |
|
218 | get :issues, :ids => [1, 4] | |
227 | assert_response :success |
|
219 | assert_response :success | |
228 | assert_template 'context_menus/issues' |
|
|||
229 |
|
220 | |||
230 | assert_include version, assigns(:versions) |
|
|||
231 | assert_select 'a', :text => 'eCookbook - Shared' |
|
221 | assert_select 'a', :text => 'eCookbook - Shared' | |
232 | end |
|
222 | end | |
233 |
|
223 | |||
@@ -245,7 +235,6 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
245 | @request.session[:user_id] = 2 |
|
235 | @request.session[:user_id] = 2 | |
246 | get :time_entries, :ids => [1, 2] |
|
236 | get :time_entries, :ids => [1, 2] | |
247 | assert_response :success |
|
237 | assert_response :success | |
248 | assert_template 'context_menus/time_entries' |
|
|||
249 |
|
238 | |||
250 | assert_select 'a:not(.disabled)', :text => 'Edit' |
|
239 | assert_select 'a:not(.disabled)', :text => 'Edit' | |
251 | end |
|
240 | end | |
@@ -254,7 +243,6 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
254 | @request.session[:user_id] = 2 |
|
243 | @request.session[:user_id] = 2 | |
255 | get :time_entries, :ids => [1] |
|
244 | get :time_entries, :ids => [1] | |
256 | assert_response :success |
|
245 | assert_response :success | |
257 | assert_template 'context_menus/time_entries' |
|
|||
258 |
|
246 | |||
259 | assert_select 'a:not(.disabled)', :text => 'Edit' |
|
247 | assert_select 'a:not(.disabled)', :text => 'Edit' | |
260 | end |
|
248 | end | |
@@ -265,6 +253,7 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
265 | @request.session[:user_id] = 2 |
|
253 | @request.session[:user_id] = 2 | |
266 | get :time_entries, :ids => [1, 2] |
|
254 | get :time_entries, :ids => [1, 2] | |
267 | assert_response :success |
|
255 | assert_response :success | |
|
256 | ||||
268 | assert_select "li.cf_#{field.id}" do |
|
257 | assert_select "li.cf_#{field.id}" do | |
269 | assert_select 'a[href="#"]', :text => "Field" |
|
258 | assert_select 'a[href="#"]', :text => "Field" | |
270 | assert_select 'ul' do |
|
259 | assert_select 'ul' do | |
@@ -284,7 +273,7 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
284 |
|
273 | |||
285 | get :time_entries, :ids => ids |
|
274 | get :time_entries, :ids => ids | |
286 | assert_response :success |
|
275 | assert_response :success | |
287 | assert_template 'context_menus/time_entries' |
|
276 | ||
288 | assert_select 'a:not(.disabled)', :text => 'Edit' |
|
277 | assert_select 'a:not(.disabled)', :text => 'Edit' | |
289 | end |
|
278 | end | |
290 |
|
279 | |||
@@ -294,7 +283,7 class ContextMenusControllerTest < Redmine::ControllerTest | |||||
294 |
|
283 | |||
295 | get :time_entries, :ids => [1, 2] |
|
284 | get :time_entries, :ids => [1, 2] | |
296 | assert_response :success |
|
285 | assert_response :success | |
297 | assert_template 'context_menus/time_entries' |
|
286 | ||
298 | assert_select 'a.disabled', :text => 'Edit' |
|
287 | assert_select 'a.disabled', :text => 'Edit' | |
299 | end |
|
288 | end | |
300 | end |
|
289 | end |
@@ -32,7 +32,10 class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest | |||||
32 | def test_index |
|
32 | def test_index | |
33 | get :index, :custom_field_id => @field.id |
|
33 | get :index, :custom_field_id => @field.id | |
34 | assert_response :success |
|
34 | assert_response :success | |
35 | assert_template 'index' |
|
35 | ||
|
36 | assert_select 'ul#custom_field_enumerations' do | |||
|
37 | assert_select 'li', 2 | |||
|
38 | end | |||
36 | end |
|
39 | end | |
37 |
|
40 | |||
38 | def test_create |
|
41 | def test_create | |
@@ -91,8 +94,9 class CustomFieldEnumerationsControllerTest < Redmine::ControllerTest | |||||
91 |
|
94 | |||
92 | assert_no_difference 'CustomFieldEnumeration.count' do |
|
95 | assert_no_difference 'CustomFieldEnumeration.count' do | |
93 | delete :destroy, :custom_field_id => @field.id, :id => @foo.id |
|
96 | delete :destroy, :custom_field_id => @field.id, :id => @foo.id | |
94 |
assert_response |
|
97 | assert_response :success | |
95 | assert_template 'destroy' |
|
98 | ||
|
99 | assert_select 'select[name=?]', 'reassign_to_id' | |||
96 | end |
|
100 | end | |
97 | end |
|
101 | end | |
98 |
|
102 |
@@ -38,27 +38,28 class CustomFieldsControllerTest < Redmine::ControllerTest | |||||
38 | def test_index |
|
38 | def test_index | |
39 | get :index |
|
39 | get :index | |
40 | assert_response :success |
|
40 | assert_response :success | |
41 | assert_template 'index' |
|
41 | ||
|
42 | assert_select 'table.custom_fields' | |||
42 | end |
|
43 | end | |
43 |
|
44 | |||
44 | def test_new_without_type_should_render_select_type |
|
45 | def test_new_without_type_should_render_select_type | |
45 | get :new |
|
46 | get :new | |
46 | assert_response :success |
|
47 | assert_response :success | |
47 | assert_template 'select_type' |
|
48 | ||
48 | assert_select 'input[name=type]', CustomFieldsHelper::CUSTOM_FIELDS_TABS.size |
|
49 | assert_select 'input[name=type]', CustomFieldsHelper::CUSTOM_FIELDS_TABS.size | |
49 | assert_select 'input[name=type][checked=checked]', 1 |
|
50 | assert_select 'input[name=type][checked=checked]', 1 | |
50 | end |
|
51 | end | |
51 |
|
52 | |||
52 | def test_new_should_work_for_each_customized_class_and_format |
|
53 | def test_new_should_work_for_each_customized_class_and_format | |
53 | custom_field_classes.each do |klass| |
|
54 | custom_field_classes.each do |klass| | |
54 |
Redmine::FieldFormat. |
|
55 | Redmine::FieldFormat.formats_for_custom_field_class(klass).each do |format| | |
55 |
get :new, :type => klass.name, :custom_field => {:field_format => format |
|
56 | get :new, :type => klass.name, :custom_field => {:field_format => format.name} | |
56 | assert_response :success |
|
57 | assert_response :success | |
57 | assert_template 'new' |
|
58 | ||
58 | assert_kind_of klass, assigns(:custom_field) |
|
|||
59 | assert_equal format_name, assigns(:custom_field).format.name |
|
|||
60 | assert_select 'form#custom_field_form' do |
|
59 | assert_select 'form#custom_field_form' do | |
61 |
assert_select 'select |
|
60 | assert_select 'select[name=?]', 'custom_field[field_format]' do | |
|
61 | assert_select 'option[value=?][selected=selected]', format.name | |||
|
62 | end | |||
62 | assert_select 'input[type=hidden][name=type][value=?]', klass.name |
|
63 | assert_select 'input[type=hidden][name=type][value=?]', klass.name | |
63 | end |
|
64 | end | |
64 | end |
|
65 | end | |
@@ -68,13 +69,16 class CustomFieldsControllerTest < Redmine::ControllerTest | |||||
68 | def test_new_should_have_string_default_format |
|
69 | def test_new_should_have_string_default_format | |
69 | get :new, :type => 'IssueCustomField' |
|
70 | get :new, :type => 'IssueCustomField' | |
70 | assert_response :success |
|
71 | assert_response :success | |
71 | assert_equal 'string', assigns(:custom_field).format.name |
|
72 | ||
|
73 | assert_select 'select[name=?]', 'custom_field[field_format]' do | |||
|
74 | assert_select 'option[value=?][selected=selected]', 'string' | |||
|
75 | end | |||
72 | end |
|
76 | end | |
73 |
|
77 | |||
74 | def test_new_issue_custom_field |
|
78 | def test_new_issue_custom_field | |
75 | get :new, :type => 'IssueCustomField' |
|
79 | get :new, :type => 'IssueCustomField' | |
76 | assert_response :success |
|
80 | assert_response :success | |
77 | assert_template 'new' |
|
81 | ||
78 | assert_select 'form#custom_field_form' do |
|
82 | assert_select 'form#custom_field_form' do | |
79 | assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]' do |
|
83 | assert_select 'select#custom_field_field_format[name=?]', 'custom_field[field_format]' do | |
80 | assert_select 'option[value=user]', :text => 'User' |
|
84 | assert_select 'option[value=user]', :text => 'User' | |
@@ -89,7 +93,7 class CustomFieldsControllerTest < Redmine::ControllerTest | |||||
89 | def test_new_time_entry_custom_field_should_not_show_trackers_and_projects |
|
93 | def test_new_time_entry_custom_field_should_not_show_trackers_and_projects | |
90 | get :new, :type => 'TimeEntryCustomField' |
|
94 | get :new, :type => 'TimeEntryCustomField' | |
91 | assert_response :success |
|
95 | assert_response :success | |
92 | assert_template 'new' |
|
96 | ||
93 | assert_select 'form#custom_field_form' do |
|
97 | assert_select 'form#custom_field_form' do | |
94 | assert_select 'input[name=?]', 'custom_field[tracker_ids][]', 0 |
|
98 | assert_select 'input[name=?]', 'custom_field[tracker_ids][]', 0 | |
95 | assert_select 'input[name=?]', 'custom_field[project_ids][]', 0 |
|
99 | assert_select 'input[name=?]', 'custom_field[project_ids][]', 0 | |
@@ -125,17 +129,16 class CustomFieldsControllerTest < Redmine::ControllerTest | |||||
125 | def test_new_js |
|
129 | def test_new_js | |
126 | xhr :get, :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'list'}, :format => 'js' |
|
130 | xhr :get, :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'list'}, :format => 'js' | |
127 | assert_response :success |
|
131 | assert_response :success | |
128 | assert_template 'new' |
|
|||
129 | assert_equal 'text/javascript', response.content_type |
|
132 | assert_equal 'text/javascript', response.content_type | |
130 |
|
133 | |||
131 | field = assigns(:custom_field) |
|
134 | assert_include '<option selected=\"selected\" value=\"list\">List<\/option>', response.body | |
132 | assert_equal 'list', field.field_format |
|
|||
133 | end |
|
135 | end | |
134 |
|
136 | |||
135 | def test_new_with_invalid_custom_field_class_should_render_select_type |
|
137 | def test_new_with_invalid_custom_field_class_should_render_select_type | |
136 | get :new, :type => 'UnknownCustomField' |
|
138 | get :new, :type => 'UnknownCustomField' | |
137 | assert_response :success |
|
139 | assert_response :success | |
138 | assert_template 'select_type' |
|
140 | ||
|
141 | assert_select 'input[type=radio][name=type]' | |||
139 | end |
|
142 | end | |
140 |
|
143 | |||
141 | def test_create_list_custom_field |
|
144 | def test_create_list_custom_field | |
@@ -176,7 +179,7 class CustomFieldsControllerTest < Redmine::ControllerTest | |||||
176 | post :create, :type => "IssueCustomField", :custom_field => {:name => ''} |
|
179 | post :create, :type => "IssueCustomField", :custom_field => {:name => ''} | |
177 | end |
|
180 | end | |
178 | assert_response :success |
|
181 | assert_response :success | |
179 | assert_template 'new' |
|
182 | assert_select_error /name cannot be blank/i | |
180 | end |
|
183 | end | |
181 |
|
184 | |||
182 | def test_create_without_type_should_render_select_type |
|
185 | def test_create_without_type_should_render_select_type | |
@@ -184,13 +187,12 class CustomFieldsControllerTest < Redmine::ControllerTest | |||||
184 | post :create, :custom_field => {:name => ''} |
|
187 | post :create, :custom_field => {:name => ''} | |
185 | end |
|
188 | end | |
186 | assert_response :success |
|
189 | assert_response :success | |
187 | assert_template 'select_type' |
|
190 | assert_select 'input[type=radio][name=type]' | |
188 | end |
|
191 | end | |
189 |
|
192 | |||
190 | def test_edit |
|
193 | def test_edit | |
191 | get :edit, :id => 1 |
|
194 | get :edit, :id => 1 | |
192 | assert_response :success |
|
195 | assert_response :success | |
193 | assert_template 'edit' |
|
|||
194 | assert_select 'input[name=?][value=?]', 'custom_field[name]', 'Database' |
|
196 | assert_select 'input[name=?][value=?]', 'custom_field[name]', 'Database' | |
195 | end |
|
197 | end | |
196 |
|
198 | |||
@@ -210,7 +212,7 class CustomFieldsControllerTest < Redmine::ControllerTest | |||||
210 | def test_update_with_failure |
|
212 | def test_update_with_failure | |
211 | put :update, :id => 1, :custom_field => {:name => ''} |
|
213 | put :update, :id => 1, :custom_field => {:name => ''} | |
212 | assert_response :success |
|
214 | assert_response :success | |
213 | assert_template 'edit' |
|
215 | assert_select_error /name cannot be blank/i | |
214 | end |
|
216 | end | |
215 |
|
217 | |||
216 | def test_destroy |
|
218 | def test_destroy |
@@ -33,8 +33,6 class DocumentsControllerTest < Redmine::ControllerTest | |||||
33 |
|
33 | |||
34 | get :index, :project_id => 'ecookbook' |
|
34 | get :index, :project_id => 'ecookbook' | |
35 | assert_response :success |
|
35 | assert_response :success | |
36 | assert_template 'index' |
|
|||
37 | assert_not_nil assigns(:grouped) |
|
|||
38 |
|
36 | |||
39 | # Default category selected in the new document form |
|
37 | # Default category selected in the new document form | |
40 | assert_select 'select[name=?]', 'document[category_id]' do |
|
38 | assert_select 'select[name=?]', 'document[category_id]' do | |
@@ -74,7 +72,6 LOREM | |||||
74 |
|
72 | |||
75 | get :index, :project_id => 'ecookbook' |
|
73 | get :index, :project_id => 'ecookbook' | |
76 | assert_response :success |
|
74 | assert_response :success | |
77 | assert_template 'index' |
|
|||
78 |
|
75 | |||
79 | # should only truncate on new lines to avoid breaking wiki formatting |
|
76 | # should only truncate on new lines to avoid breaking wiki formatting | |
80 | assert_select '.wiki p', :text => (doc.description.split("\n").first + '...') |
|
77 | assert_select '.wiki p', :text => (doc.description.split("\n").first + '...') | |
@@ -84,14 +81,12 LOREM | |||||
84 | def test_show |
|
81 | def test_show | |
85 | get :show, :id => 1 |
|
82 | get :show, :id => 1 | |
86 | assert_response :success |
|
83 | assert_response :success | |
87 | assert_template 'show' |
|
|||
88 | end |
|
84 | end | |
89 |
|
85 | |||
90 | def test_new |
|
86 | def test_new | |
91 | @request.session[:user_id] = 2 |
|
87 | @request.session[:user_id] = 2 | |
92 | get :new, :project_id => 1 |
|
88 | get :new, :project_id => 1 | |
93 | assert_response :success |
|
89 | assert_response :success | |
94 | assert_template 'new' |
|
|||
95 | end |
|
90 | end | |
96 |
|
91 | |||
97 | def test_create_with_one_attachment |
|
92 | def test_create_with_one_attachment | |
@@ -122,7 +117,7 LOREM | |||||
122 | post :create, :project_id => 'ecookbook', :document => { :title => ''} |
|
117 | post :create, :project_id => 'ecookbook', :document => { :title => ''} | |
123 | end |
|
118 | end | |
124 | assert_response :success |
|
119 | assert_response :success | |
125 | assert_template 'new' |
|
120 | assert_select_error /title cannot be blank/i | |
126 | end |
|
121 | end | |
127 |
|
122 | |||
128 | def test_create_non_default_category |
|
123 | def test_create_non_default_category | |
@@ -146,7 +141,6 LOREM | |||||
146 | @request.session[:user_id] = 2 |
|
141 | @request.session[:user_id] = 2 | |
147 | get :edit, :id => 1 |
|
142 | get :edit, :id => 1 | |
148 | assert_response :success |
|
143 | assert_response :success | |
149 | assert_template 'edit' |
|
|||
150 | end |
|
144 | end | |
151 |
|
145 | |||
152 | def test_update |
|
146 | def test_update | |
@@ -161,7 +155,7 LOREM | |||||
161 | @request.session[:user_id] = 2 |
|
155 | @request.session[:user_id] = 2 | |
162 | put :update, :id => 1, :document => {:title => ''} |
|
156 | put :update, :id => 1, :document => {:title => ''} | |
163 | assert_response :success |
|
157 | assert_response :success | |
164 | assert_template 'edit' |
|
158 | assert_select_error /title cannot be blank/i | |
165 | end |
|
159 | end | |
166 |
|
160 | |||
167 | def test_destroy |
|
161 | def test_destroy |
@@ -28,7 +28,6 class EmailAddressesControllerTest < Redmine::ControllerTest | |||||
28 | @request.session[:user_id] = 2 |
|
28 | @request.session[:user_id] = 2 | |
29 | get :index, :user_id => 2 |
|
29 | get :index, :user_id => 2 | |
30 | assert_response :success |
|
30 | assert_response :success | |
31 | assert_template 'index' |
|
|||
32 | end |
|
31 | end | |
33 |
|
32 | |||
34 | def test_index_with_additional_emails |
|
33 | def test_index_with_additional_emails | |
@@ -37,7 +36,6 class EmailAddressesControllerTest < Redmine::ControllerTest | |||||
37 |
|
36 | |||
38 | get :index, :user_id => 2 |
|
37 | get :index, :user_id => 2 | |
39 | assert_response :success |
|
38 | assert_response :success | |
40 | assert_template 'index' |
|
|||
41 | assert_select '.email', :text => 'another@somenet.foo' |
|
39 | assert_select '.email', :text => 'another@somenet.foo' | |
42 | end |
|
40 | end | |
43 |
|
41 | |||
@@ -47,7 +45,6 class EmailAddressesControllerTest < Redmine::ControllerTest | |||||
47 |
|
45 | |||
48 | xhr :get, :index, :user_id => 2 |
|
46 | xhr :get, :index, :user_id => 2 | |
49 | assert_response :success |
|
47 | assert_response :success | |
50 | assert_template 'index' |
|
|||
51 | assert_include 'another@somenet.foo', response.body |
|
48 | assert_include 'another@somenet.foo', response.body | |
52 | end |
|
49 | end | |
53 |
|
50 | |||
@@ -55,7 +52,6 class EmailAddressesControllerTest < Redmine::ControllerTest | |||||
55 | @request.session[:user_id] = 1 |
|
52 | @request.session[:user_id] = 1 | |
56 | get :index, :user_id => 2 |
|
53 | get :index, :user_id => 2 | |
57 | assert_response :success |
|
54 | assert_response :success | |
58 | assert_template 'index' |
|
|||
59 | end |
|
55 | end | |
60 |
|
56 | |||
61 | def test_index_by_another_user_should_be_denied |
|
57 | def test_index_by_another_user_should_be_denied | |
@@ -88,7 +84,8 class EmailAddressesControllerTest < Redmine::ControllerTest | |||||
88 | @request.session[:user_id] = 2 |
|
84 | @request.session[:user_id] = 2 | |
89 | assert_no_difference 'EmailAddress.count' do |
|
85 | assert_no_difference 'EmailAddress.count' do | |
90 | post :create, :user_id => 2, :email_address => {:address => 'invalid'} |
|
86 | post :create, :user_id => 2, :email_address => {:address => 'invalid'} | |
91 |
assert_response |
|
87 | assert_response :success | |
|
88 | assert_select_error /email is invalid/i | |||
92 | end |
|
89 | end | |
93 | end |
|
90 | end | |
94 |
|
91 |
@@ -27,7 +27,7 class EnumerationsControllerTest < Redmine::ControllerTest | |||||
27 | def test_index |
|
27 | def test_index | |
28 | get :index |
|
28 | get :index | |
29 | assert_response :success |
|
29 | assert_response :success | |
30 | assert_template 'index' |
|
30 | assert_select 'table.enumerations' | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def test_index_should_require_admin |
|
33 | def test_index_should_require_admin | |
@@ -39,8 +39,7 class EnumerationsControllerTest < Redmine::ControllerTest | |||||
39 | def test_new |
|
39 | def test_new | |
40 | get :new, :type => 'IssuePriority' |
|
40 | get :new, :type => 'IssuePriority' | |
41 | assert_response :success |
|
41 | assert_response :success | |
42 | assert_template 'new' |
|
42 | ||
43 | assert_kind_of IssuePriority, assigns(:enumeration) |
|
|||
44 | assert_select 'input[name=?][value=?]', 'enumeration[type]', 'IssuePriority' |
|
43 | assert_select 'input[name=?][value=?]', 'enumeration[type]', 'IssuePriority' | |
45 | assert_select 'input[name=?]', 'enumeration[name]' |
|
44 | assert_select 'input[name=?]', 'enumeration[name]' | |
46 | end |
|
45 | end | |
@@ -64,13 +63,12 class EnumerationsControllerTest < Redmine::ControllerTest | |||||
64 | post :create, :enumeration => {:type => 'IssuePriority', :name => ''} |
|
63 | post :create, :enumeration => {:type => 'IssuePriority', :name => ''} | |
65 | end |
|
64 | end | |
66 | assert_response :success |
|
65 | assert_response :success | |
67 | assert_template 'new' |
|
66 | assert_select_error /name cannot be blank/i | |
68 | end |
|
67 | end | |
69 |
|
68 | |||
70 | def test_edit |
|
69 | def test_edit | |
71 | get :edit, :id => 6 |
|
70 | get :edit, :id => 6 | |
72 | assert_response :success |
|
71 | assert_response :success | |
73 | assert_template 'edit' |
|
|||
74 | assert_select 'input[name=?][value=?]', 'enumeration[name]', 'High' |
|
72 | assert_select 'input[name=?][value=?]', 'enumeration[name]', 'High' | |
75 | end |
|
73 | end | |
76 |
|
74 | |||
@@ -93,7 +91,7 class EnumerationsControllerTest < Redmine::ControllerTest | |||||
93 | put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => ''} |
|
91 | put :update, :id => 6, :enumeration => {:type => 'IssuePriority', :name => ''} | |
94 | end |
|
92 | end | |
95 | assert_response :success |
|
93 | assert_response :success | |
96 | assert_template 'edit' |
|
94 | assert_select_error /name cannot be blank/i | |
97 | end |
|
95 | end | |
98 |
|
96 | |||
99 | def test_destroy_enumeration_not_in_use |
|
97 | def test_destroy_enumeration_not_in_use | |
@@ -109,7 +107,7 class EnumerationsControllerTest < Redmine::ControllerTest | |||||
109 | delete :destroy, :id => 4 |
|
107 | delete :destroy, :id => 4 | |
110 | end |
|
108 | end | |
111 | assert_response :success |
|
109 | assert_response :success | |
112 | assert_template 'destroy' |
|
110 | ||
113 | assert_not_nil Enumeration.find_by_id(4) |
|
111 | assert_not_nil Enumeration.find_by_id(4) | |
114 | assert_select 'select[name=reassign_to_id]' do |
|
112 | assert_select 'select[name=reassign_to_id]' do | |
115 | assert_select 'option[value="6"]', :text => 'High' |
|
113 | assert_select 'option[value="6"]', :text => 'High' |
@@ -39,8 +39,6 class FilesControllerTest < Redmine::ControllerTest | |||||
39 | def test_index |
|
39 | def test_index | |
40 | get :index, :project_id => 1 |
|
40 | get :index, :project_id => 1 | |
41 | assert_response :success |
|
41 | assert_response :success | |
42 | assert_template 'index' |
|
|||
43 | assert_not_nil assigns(:containers) |
|
|||
44 |
|
42 | |||
45 | # file attached to the project |
|
43 | # file attached to the project | |
46 | assert_select 'a[href=?]', '/attachments/download/8/project_file.zip', :text => 'project_file.zip' |
|
44 | assert_select 'a[href=?]', '/attachments/download/8/project_file.zip', :text => 'project_file.zip' | |
@@ -53,7 +51,6 class FilesControllerTest < Redmine::ControllerTest | |||||
53 | @request.session[:user_id] = 2 |
|
51 | @request.session[:user_id] = 2 | |
54 | get :new, :project_id => 1 |
|
52 | get :new, :project_id => 1 | |
55 | assert_response :success |
|
53 | assert_response :success | |
56 | assert_template 'new' |
|
|||
57 |
|
54 | |||
58 | assert_select 'select[name=?]', 'version_id' |
|
55 | assert_select 'select[name=?]', 'version_id' | |
59 | end |
|
56 | end | |
@@ -63,7 +60,6 class FilesControllerTest < Redmine::ControllerTest | |||||
63 | @request.session[:user_id] = 2 |
|
60 | @request.session[:user_id] = 2 | |
64 | get :new, :project_id => 1 |
|
61 | get :new, :project_id => 1 | |
65 | assert_response :success |
|
62 | assert_response :success | |
66 | assert_template 'new' |
|
|||
67 |
|
63 | |||
68 | assert_select 'select[name=?]', 'version_id', 0 |
|
64 | assert_select 'select[name=?]', 'version_id', 0 | |
69 | end |
|
65 | end | |
@@ -112,8 +108,7 class FilesControllerTest < Redmine::ControllerTest | |||||
112 |
|
108 | |||
113 | assert_no_difference 'Attachment.count' do |
|
109 | assert_no_difference 'Attachment.count' do | |
114 | post :create, :project_id => 1, :version_id => '' |
|
110 | post :create, :project_id => 1, :version_id => '' | |
115 |
assert_response |
|
111 | assert_response :success | |
116 | assert_template 'new' |
|
|||
117 | end |
|
112 | end | |
118 | assert_select 'div.error', 'File is invalid' |
|
113 | assert_select 'div.error', 'File is invalid' | |
119 | end |
|
114 | end |
@@ -32,8 +32,7 class GanttsControllerTest < Redmine::ControllerTest | |||||
32 | i2.update_attribute(:due_date, 1.month.from_now) |
|
32 | i2.update_attribute(:due_date, 1.month.from_now) | |
33 | get :show, :project_id => 1 |
|
33 | get :show, :project_id => 1 | |
34 | assert_response :success |
|
34 | assert_response :success | |
35 | assert_template 'gantts/show' |
|
35 | ||
36 | assert_not_nil assigns(:gantt) |
|
|||
37 | # Issue with start and due dates |
|
36 | # Issue with start and due dates | |
38 | i = Issue.find(1) |
|
37 | i = Issue.find(1) | |
39 | assert_not_nil i.due_date |
|
38 | assert_not_nil i.due_date | |
@@ -46,21 +45,19 class GanttsControllerTest < Redmine::ControllerTest | |||||
46 | def test_gantt_at_minimal_zoom |
|
45 | def test_gantt_at_minimal_zoom | |
47 | get :show, :project_id => 1, :zoom => 1 |
|
46 | get :show, :project_id => 1, :zoom => 1 | |
48 | assert_response :success |
|
47 | assert_response :success | |
49 | assert_equal 1, assigns(:gantt).zoom |
|
48 | assert_select 'input[type=hidden][name=zoom][value=?]', '1' | |
50 | end |
|
49 | end | |
51 |
|
50 | |||
52 | def test_gantt_at_maximal_zoom |
|
51 | def test_gantt_at_maximal_zoom | |
53 | get :show, :project_id => 1, :zoom => 4 |
|
52 | get :show, :project_id => 1, :zoom => 4 | |
54 | assert_response :success |
|
53 | assert_response :success | |
55 | assert_equal 4, assigns(:gantt).zoom |
|
54 | assert_select 'input[type=hidden][name=zoom][value=?]', '4' | |
56 | end |
|
55 | end | |
57 |
|
56 | |||
58 | def test_gantt_should_work_without_issue_due_dates |
|
57 | def test_gantt_should_work_without_issue_due_dates | |
59 | Issue.update_all("due_date = NULL") |
|
58 | Issue.update_all("due_date = NULL") | |
60 | get :show, :project_id => 1 |
|
59 | get :show, :project_id => 1 | |
61 | assert_response :success |
|
60 | assert_response :success | |
62 | assert_template 'gantts/show' |
|
|||
63 | assert_not_nil assigns(:gantt) |
|
|||
64 | end |
|
61 | end | |
65 |
|
62 | |||
66 | def test_gantt_should_work_without_issue_and_version_due_dates |
|
63 | def test_gantt_should_work_without_issue_and_version_due_dates | |
@@ -68,23 +65,17 class GanttsControllerTest < Redmine::ControllerTest | |||||
68 | Version.update_all("effective_date = NULL") |
|
65 | Version.update_all("effective_date = NULL") | |
69 | get :show, :project_id => 1 |
|
66 | get :show, :project_id => 1 | |
70 | assert_response :success |
|
67 | assert_response :success | |
71 | assert_template 'gantts/show' |
|
|||
72 | assert_not_nil assigns(:gantt) |
|
|||
73 | end |
|
68 | end | |
74 |
|
69 | |||
75 | def test_gantt_should_work_cross_project |
|
70 | def test_gantt_should_work_cross_project | |
76 | get :show |
|
71 | get :show | |
77 | assert_response :success |
|
72 | assert_response :success | |
78 | assert_template 'gantts/show' |
|
|||
79 | assert_not_nil assigns(:gantt) |
|
|||
80 | assert_not_nil assigns(:gantt).query |
|
|||
81 | assert_nil assigns(:gantt).project |
|
|||
82 | end |
|
73 | end | |
83 |
|
74 | |||
84 | def test_gantt_should_not_disclose_private_projects |
|
75 | def test_gantt_should_not_disclose_private_projects | |
85 | get :show |
|
76 | get :show | |
86 | assert_response :success |
|
77 | assert_response :success | |
87 | assert_template 'gantts/show' |
|
78 | ||
88 | assert_select 'a', :text => /eCookbook/ |
|
79 | assert_select 'a', :text => /eCookbook/ | |
89 | # Root private project |
|
80 | # Root private project | |
90 | assert_select 'a', :text => /OnlineStore/, :count => 0 |
|
81 | assert_select 'a', :text => /OnlineStore/, :count => 0 | |
@@ -101,9 +92,6 class GanttsControllerTest < Redmine::ControllerTest | |||||
101 | get :show |
|
92 | get :show | |
102 | assert_response :success |
|
93 | assert_response :success | |
103 |
|
94 | |||
104 | relations = assigns(:gantt).relations |
|
|||
105 | assert_kind_of Hash, relations |
|
|||
106 | assert relations.present? |
|
|||
107 | assert_select 'div.task_todo[id=?][data-rels*=?]', "task-todo-issue-#{issue1.id}", issue2.id.to_s |
|
95 | assert_select 'div.task_todo[id=?][data-rels*=?]', "task-todo-issue-#{issue1.id}", issue2.id.to_s | |
108 | assert_select 'div.task_todo[id=?]:not([data-rels])', "task-todo-issue-#{issue2.id}" |
|
96 | assert_select 'div.task_todo[id=?]:not([data-rels])', "task-todo-issue-#{issue2.id}" | |
109 | end |
|
97 | end | |
@@ -113,7 +101,6 class GanttsControllerTest < Redmine::ControllerTest | |||||
113 | assert_response :success |
|
101 | assert_response :success | |
114 | assert_equal 'application/pdf', @response.content_type |
|
102 | assert_equal 'application/pdf', @response.content_type | |
115 | assert @response.body.starts_with?('%PDF') |
|
103 | assert @response.body.starts_with?('%PDF') | |
116 | assert_not_nil assigns(:gantt) |
|
|||
117 | end |
|
104 | end | |
118 |
|
105 | |||
119 | def test_gantt_should_export_to_pdf_cross_project |
|
106 | def test_gantt_should_export_to_pdf_cross_project | |
@@ -121,7 +108,6 class GanttsControllerTest < Redmine::ControllerTest | |||||
121 | assert_response :success |
|
108 | assert_response :success | |
122 | assert_equal 'application/pdf', @response.content_type |
|
109 | assert_equal 'application/pdf', @response.content_type | |
123 | assert @response.body.starts_with?('%PDF') |
|
110 | assert @response.body.starts_with?('%PDF') | |
124 | assert_not_nil assigns(:gantt) |
|
|||
125 | end |
|
111 | end | |
126 |
|
112 | |||
127 | if Object.const_defined?(:Magick) |
|
113 | if Object.const_defined?(:Magick) |
@@ -27,7 +27,7 class GroupsControllerTest < Redmine::ControllerTest | |||||
27 | def test_index |
|
27 | def test_index | |
28 | get :index |
|
28 | get :index | |
29 | assert_response :success |
|
29 | assert_response :success | |
30 | assert_template 'index' |
|
30 | assert_select 'table.groups' | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def test_index_should_show_user_count |
|
33 | def test_index_should_show_user_count | |
@@ -39,7 +39,6 class GroupsControllerTest < Redmine::ControllerTest | |||||
39 | def test_show |
|
39 | def test_show | |
40 | get :show, :id => 10 |
|
40 | get :show, :id => 10 | |
41 | assert_response :success |
|
41 | assert_response :success | |
42 | assert_template 'show' |
|
|||
43 | end |
|
42 | end | |
44 |
|
43 | |||
45 | def test_show_invalid_should_return_404 |
|
44 | def test_show_invalid_should_return_404 | |
@@ -50,7 +49,6 class GroupsControllerTest < Redmine::ControllerTest | |||||
50 | def test_new |
|
49 | def test_new | |
51 | get :new |
|
50 | get :new | |
52 | assert_response :success |
|
51 | assert_response :success | |
53 | assert_template 'new' |
|
|||
54 | assert_select 'input[name=?]', 'group[name]' |
|
52 | assert_select 'input[name=?]', 'group[name]' | |
55 | end |
|
53 | end | |
56 |
|
54 | |||
@@ -78,13 +76,12 class GroupsControllerTest < Redmine::ControllerTest | |||||
78 | post :create, :group => {:name => ''} |
|
76 | post :create, :group => {:name => ''} | |
79 | end |
|
77 | end | |
80 | assert_response :success |
|
78 | assert_response :success | |
81 | assert_template 'new' |
|
79 | assert_select_error /Name cannot be blank/i | |
82 | end |
|
80 | end | |
83 |
|
81 | |||
84 | def test_edit |
|
82 | def test_edit | |
85 | get :edit, :id => 10 |
|
83 | get :edit, :id => 10 | |
86 | assert_response :success |
|
84 | assert_response :success | |
87 | assert_template 'edit' |
|
|||
88 |
|
85 | |||
89 | assert_select 'div#tab-content-users' |
|
86 | assert_select 'div#tab-content-users' | |
90 | assert_select 'div#tab-content-memberships' do |
|
87 | assert_select 'div#tab-content-memberships' do | |
@@ -103,7 +100,7 class GroupsControllerTest < Redmine::ControllerTest | |||||
103 | def test_update_with_failure |
|
100 | def test_update_with_failure | |
104 | put :update, :id => 10, :group => {:name => ''} |
|
101 | put :update, :id => 10, :group => {:name => ''} | |
105 | assert_response :success |
|
102 | assert_response :success | |
106 | assert_template 'edit' |
|
103 | assert_select_error /Name cannot be blank/i | |
107 | end |
|
104 | end | |
108 |
|
105 | |||
109 | def test_destroy |
|
106 | def test_destroy | |
@@ -116,7 +113,7 class GroupsControllerTest < Redmine::ControllerTest | |||||
116 | def test_new_users |
|
113 | def test_new_users | |
117 | get :new_users, :id => 10 |
|
114 | get :new_users, :id => 10 | |
118 | assert_response :success |
|
115 | assert_response :success | |
119 | assert_template 'new_users' |
|
116 | assert_select 'input[name=?]', 'user_search' | |
120 | end |
|
117 | end | |
121 |
|
118 | |||
122 | def test_xhr_new_users |
|
119 | def test_xhr_new_users | |
@@ -135,7 +132,6 class GroupsControllerTest < Redmine::ControllerTest | |||||
135 | assert_difference 'Group.find(10).users.count', 2 do |
|
132 | assert_difference 'Group.find(10).users.count', 2 do | |
136 | xhr :post, :add_users, :id => 10, :user_ids => ['2', '3'] |
|
133 | xhr :post, :add_users, :id => 10, :user_ids => ['2', '3'] | |
137 | assert_response :success |
|
134 | assert_response :success | |
138 | assert_template 'add_users' |
|
|||
139 | assert_equal 'text/javascript', response.content_type |
|
135 | assert_equal 'text/javascript', response.content_type | |
140 | end |
|
136 | end | |
141 | assert_match /John Smith/, response.body |
|
137 | assert_match /John Smith/, response.body | |
@@ -151,7 +147,6 class GroupsControllerTest < Redmine::ControllerTest | |||||
151 | assert_difference 'Group.find(10).users.count', -1 do |
|
147 | assert_difference 'Group.find(10).users.count', -1 do | |
152 | xhr :delete, :remove_user, :id => 10, :user_id => '8' |
|
148 | xhr :delete, :remove_user, :id => 10, :user_id => '8' | |
153 | assert_response :success |
|
149 | assert_response :success | |
154 | assert_template 'remove_user' |
|
|||
155 | assert_equal 'text/javascript', response.content_type |
|
150 | assert_equal 'text/javascript', response.content_type | |
156 | end |
|
151 | end | |
157 | end |
|
152 | end |
@@ -44,7 +44,6 class ImportsControllerTest < Redmine::ControllerTest | |||||
44 | def test_new_should_display_the_upload_form |
|
44 | def test_new_should_display_the_upload_form | |
45 | get :new |
|
45 | get :new | |
46 | assert_response :success |
|
46 | assert_response :success | |
47 | assert_template 'new' |
|
|||
48 | assert_select 'input[name=?]', 'file' |
|
47 | assert_select 'input[name=?]', 'file' | |
49 | end |
|
48 | end | |
50 |
|
49 | |||
@@ -62,7 +61,10 class ImportsControllerTest < Redmine::ControllerTest | |||||
62 | import = generate_import |
|
61 | import = generate_import | |
63 | get :settings, :id => import.to_param |
|
62 | get :settings, :id => import.to_param | |
64 | assert_response :success |
|
63 | assert_response :success | |
65 | assert_template 'settings' |
|
64 | assert_select 'select[name=?]', 'import_settings[separator]' | |
|
65 | assert_select 'select[name=?]', 'import_settings[wrapper]' | |||
|
66 | assert_select 'select[name=?]', 'import_settings[encoding]' | |||
|
67 | assert_select 'select[name=?]', 'import_settings[date_format]' | |||
66 | end |
|
68 | end | |
67 |
|
69 | |||
68 | def test_post_settings_should_update_settings |
|
70 | def test_post_settings_should_update_settings | |
@@ -107,7 +109,6 class ImportsControllerTest < Redmine::ControllerTest | |||||
107 |
|
109 | |||
108 | get :mapping, :id => import.to_param |
|
110 | get :mapping, :id => import.to_param | |
109 | assert_response :success |
|
111 | assert_response :success | |
110 | assert_template 'mapping' |
|
|||
111 |
|
112 | |||
112 | assert_select 'select[name=?]', 'import_settings[mapping][subject]' do |
|
113 | assert_select 'select[name=?]', 'import_settings[mapping][subject]' do | |
113 | assert_select 'option', 4 |
|
114 | assert_select 'option', 4 | |
@@ -139,7 +140,7 class ImportsControllerTest < Redmine::ControllerTest | |||||
139 |
|
140 | |||
140 | get :run, :id => import |
|
141 | get :run, :id => import | |
141 | assert_response :success |
|
142 | assert_response :success | |
142 | assert_template 'run' |
|
143 | assert_select '#import-progress' | |
143 | end |
|
144 | end | |
144 |
|
145 | |||
145 | def test_post_run_should_import_the_file |
|
146 | def test_post_run_should_import_the_file | |
@@ -183,7 +184,7 class ImportsControllerTest < Redmine::ControllerTest | |||||
183 |
|
184 | |||
184 | get :show, :id => import.to_param |
|
185 | get :show, :id => import.to_param | |
185 | assert_response :success |
|
186 | assert_response :success | |
186 | assert_template 'show' |
|
187 | ||
187 | assert_select 'ul#saved-items' |
|
188 | assert_select 'ul#saved-items' | |
188 | assert_select 'ul#saved-items li', import.saved_items.count |
|
189 | assert_select 'ul#saved-items li', import.saved_items.count | |
189 | assert_select 'table#unsaved-items', 0 |
|
190 | assert_select 'table#unsaved-items', 0 | |
@@ -197,7 +198,7 class ImportsControllerTest < Redmine::ControllerTest | |||||
197 |
|
198 | |||
198 | get :show, :id => import.to_param |
|
199 | get :show, :id => import.to_param | |
199 | assert_response :success |
|
200 | assert_response :success | |
200 | assert_template 'show' |
|
201 | ||
201 | assert_select 'table#unsaved-items' |
|
202 | assert_select 'table#unsaved-items' | |
202 | assert_select 'table#unsaved-items tbody tr', import.unsaved_items.count |
|
203 | assert_select 'table#unsaved-items tbody tr', import.unsaved_items.count | |
203 | end |
|
204 | end |
@@ -30,7 +30,6 class IssueCategoriesControllerTest < Redmine::ControllerTest | |||||
30 | @request.session[:user_id] = 2 # manager |
|
30 | @request.session[:user_id] = 2 # manager | |
31 | get :new, :project_id => '1' |
|
31 | get :new, :project_id => '1' | |
32 | assert_response :success |
|
32 | assert_response :success | |
33 | assert_template 'new' |
|
|||
34 | assert_select 'input[name=?]', 'issue_category[name]' |
|
33 | assert_select 'input[name=?]', 'issue_category[name]' | |
35 | end |
|
34 | end | |
36 |
|
35 | |||
@@ -39,7 +38,6 class IssueCategoriesControllerTest < Redmine::ControllerTest | |||||
39 | xhr :get, :new, :project_id => '1' |
|
38 | xhr :get, :new, :project_id => '1' | |
40 |
|
39 | |||
41 | assert_response :success |
|
40 | assert_response :success | |
42 | assert_template 'new' |
|
|||
43 | assert_equal 'text/javascript', response.content_type |
|
41 | assert_equal 'text/javascript', response.content_type | |
44 | end |
|
42 | end | |
45 |
|
43 | |||
@@ -58,7 +56,7 class IssueCategoriesControllerTest < Redmine::ControllerTest | |||||
58 | @request.session[:user_id] = 2 |
|
56 | @request.session[:user_id] = 2 | |
59 | post :create, :project_id => '1', :issue_category => {:name => ''} |
|
57 | post :create, :project_id => '1', :issue_category => {:name => ''} | |
60 | assert_response :success |
|
58 | assert_response :success | |
61 | assert_template 'new' |
|
59 | assert_select_error /Name cannot be blank/i | |
62 | end |
|
60 | end | |
63 |
|
61 | |||
64 | def test_create_from_issue_form |
|
62 | def test_create_from_issue_form | |
@@ -70,7 +68,6 class IssueCategoriesControllerTest < Redmine::ControllerTest | |||||
70 | assert_equal 'New category', category.name |
|
68 | assert_equal 'New category', category.name | |
71 |
|
69 | |||
72 | assert_response :success |
|
70 | assert_response :success | |
73 | assert_template 'create' |
|
|||
74 | assert_equal 'text/javascript', response.content_type |
|
71 | assert_equal 'text/javascript', response.content_type | |
75 | end |
|
72 | end | |
76 |
|
73 | |||
@@ -81,15 +78,14 class IssueCategoriesControllerTest < Redmine::ControllerTest | |||||
81 | end |
|
78 | end | |
82 |
|
79 | |||
83 | assert_response :success |
|
80 | assert_response :success | |
84 | assert_template 'new' |
|
|||
85 | assert_equal 'text/javascript', response.content_type |
|
81 | assert_equal 'text/javascript', response.content_type | |
|
82 | assert_include 'Name cannot be blank', response.body | |||
86 | end |
|
83 | end | |
87 |
|
84 | |||
88 | def test_edit |
|
85 | def test_edit | |
89 | @request.session[:user_id] = 2 |
|
86 | @request.session[:user_id] = 2 | |
90 | get :edit, :id => 2 |
|
87 | get :edit, :id => 2 | |
91 | assert_response :success |
|
88 | assert_response :success | |
92 | assert_template 'edit' |
|
|||
93 | assert_select 'input[name=?][value=?]', 'issue_category[name]', 'Recipes' |
|
89 | assert_select 'input[name=?][value=?]', 'issue_category[name]', 'Recipes' | |
94 | end |
|
90 | end | |
95 |
|
91 | |||
@@ -104,7 +100,7 class IssueCategoriesControllerTest < Redmine::ControllerTest | |||||
104 | def test_update_failure |
|
100 | def test_update_failure | |
105 | put :update, :id => 2, :issue_category => { :name => '' } |
|
101 | put :update, :id => 2, :issue_category => { :name => '' } | |
106 | assert_response :success |
|
102 | assert_response :success | |
107 | assert_template 'edit' |
|
103 | assert_select_error /Name cannot be blank/i | |
108 | end |
|
104 | end | |
109 |
|
105 | |||
110 | def test_update_not_found |
|
106 | def test_update_not_found | |
@@ -121,8 +117,8 class IssueCategoriesControllerTest < Redmine::ControllerTest | |||||
121 | def test_destroy_category_in_use |
|
117 | def test_destroy_category_in_use | |
122 | delete :destroy, :id => 1 |
|
118 | delete :destroy, :id => 1 | |
123 | assert_response :success |
|
119 | assert_response :success | |
124 | assert_template 'destroy' |
|
|||
125 | assert_not_nil IssueCategory.find_by_id(1) |
|
120 | assert_not_nil IssueCategory.find_by_id(1) | |
|
121 | assert_select 'select[name=?]', 'reassign_to_id' | |||
126 | end |
|
122 | end | |
127 |
|
123 | |||
128 | def test_destroy_category_in_use_with_reassignment |
|
124 | def test_destroy_category_in_use_with_reassignment |
@@ -59,14 +59,13 class IssueRelationsControllerTest < Redmine::ControllerTest | |||||
59 | assert_difference 'IssueRelation.count' do |
|
59 | assert_difference 'IssueRelation.count' do | |
60 | xhr :post, :create, :issue_id => 3, :relation => {:issue_to_id => '1', :relation_type => 'relates', :delay => ''} |
|
60 | xhr :post, :create, :issue_id => 3, :relation => {:issue_to_id => '1', :relation_type => 'relates', :delay => ''} | |
61 | assert_response :success |
|
61 | assert_response :success | |
62 | assert_template 'create' |
|
|||
63 | assert_equal 'text/javascript', response.content_type |
|
62 | assert_equal 'text/javascript', response.content_type | |
64 | end |
|
63 | end | |
65 | relation = IssueRelation.order('id DESC').first |
|
64 | relation = IssueRelation.order('id DESC').first | |
66 | assert_equal 3, relation.issue_from_id |
|
65 | assert_equal 3, relation.issue_from_id | |
67 | assert_equal 1, relation.issue_to_id |
|
66 | assert_equal 1, relation.issue_to_id | |
68 |
|
67 | |||
69 |
assert_ |
|
68 | assert_include 'Bug #1', response.body | |
70 | end |
|
69 | end | |
71 |
|
70 | |||
72 | def test_create_should_accept_id_with_hash |
|
71 | def test_create_should_accept_id_with_hash | |
@@ -104,7 +103,7 class IssueRelationsControllerTest < Redmine::ControllerTest | |||||
104 | xhr :post, :create, :issue_id => issue2.id, |
|
103 | xhr :post, :create, :issue_id => issue2.id, | |
105 | :relation => {:issue_to_id => issue1.id, :relation_type => 'follows', :delay => ''} |
|
104 | :relation => {:issue_to_id => issue1.id, :relation_type => 'follows', :delay => ''} | |
106 | end |
|
105 | end | |
107 |
assert_ |
|
106 | assert_include 'Followed issue', response.body | |
108 | end |
|
107 | end | |
109 |
|
108 | |||
110 | def test_should_create_relations_with_visible_issues_only |
|
109 | def test_should_create_relations_with_visible_issues_only | |
@@ -122,11 +121,9 class IssueRelationsControllerTest < Redmine::ControllerTest | |||||
122 | xhr :post, :create, :issue_id => 3, :relation => {:issue_to_id => '999', :relation_type => 'relates', :delay => ''} |
|
121 | xhr :post, :create, :issue_id => 3, :relation => {:issue_to_id => '999', :relation_type => 'relates', :delay => ''} | |
123 |
|
122 | |||
124 | assert_response :success |
|
123 | assert_response :success | |
125 | assert_template 'create' |
|
|||
126 | assert_equal 'text/javascript', response.content_type |
|
124 | assert_equal 'text/javascript', response.content_type | |
127 | end |
|
125 | end | |
128 |
|
126 | assert_include 'Related issue cannot be blank', response.body | ||
129 | assert_match /errorExplanation/, response.body |
|
|||
130 | end |
|
127 | end | |
131 |
|
128 | |||
132 | def test_destroy |
|
129 | def test_destroy | |
@@ -152,9 +149,8 class IssueRelationsControllerTest < Redmine::ControllerTest | |||||
152 | xhr :delete, :destroy, :id => '2' |
|
149 | xhr :delete, :destroy, :id => '2' | |
153 |
|
150 | |||
154 | assert_response :success |
|
151 | assert_response :success | |
155 | assert_template 'destroy' |
|
|||
156 | assert_equal 'text/javascript', response.content_type |
|
152 | assert_equal 'text/javascript', response.content_type | |
157 |
assert_ |
|
153 | assert_include 'relation-2', response.body | |
158 | end |
|
154 | end | |
159 | end |
|
155 | end | |
160 | end |
|
156 | end |
@@ -28,7 +28,7 class IssueStatusesControllerTest < Redmine::ControllerTest | |||||
28 | def test_index |
|
28 | def test_index | |
29 | get :index |
|
29 | get :index | |
30 | assert_response :success |
|
30 | assert_response :success | |
31 | assert_template 'index' |
|
31 | assert_select 'table.issue_statuses' | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_index_by_anonymous_should_redirect_to_login_form |
|
34 | def test_index_by_anonymous_should_redirect_to_login_form | |
@@ -46,7 +46,7 class IssueStatusesControllerTest < Redmine::ControllerTest | |||||
46 | def test_new |
|
46 | def test_new | |
47 | get :new |
|
47 | get :new | |
48 | assert_response :success |
|
48 | assert_response :success | |
49 | assert_template 'new' |
|
49 | assert_select 'input[name=?]', 'issue_status[name]' | |
50 | end |
|
50 | end | |
51 |
|
51 | |||
52 | def test_create |
|
52 | def test_create | |
@@ -61,14 +61,13 class IssueStatusesControllerTest < Redmine::ControllerTest | |||||
61 | def test_create_with_failure |
|
61 | def test_create_with_failure | |
62 | post :create, :issue_status => {:name => ''} |
|
62 | post :create, :issue_status => {:name => ''} | |
63 | assert_response :success |
|
63 | assert_response :success | |
64 | assert_template 'new' |
|
|||
65 | assert_select_error /name cannot be blank/i |
|
64 | assert_select_error /name cannot be blank/i | |
66 | end |
|
65 | end | |
67 |
|
66 | |||
68 | def test_edit |
|
67 | def test_edit | |
69 | get :edit, :id => '3' |
|
68 | get :edit, :id => '3' | |
70 | assert_response :success |
|
69 | assert_response :success | |
71 | assert_template 'edit' |
|
70 | assert_select 'input[name=?][value=?]', 'issue_status[name]', 'Resolved' | |
72 | end |
|
71 | end | |
73 |
|
72 | |||
74 | def test_update |
|
73 | def test_update | |
@@ -81,7 +80,6 class IssueStatusesControllerTest < Redmine::ControllerTest | |||||
81 | def test_update_with_failure |
|
80 | def test_update_with_failure | |
82 | put :update, :id => '3', :issue_status => {:name => ''} |
|
81 | put :update, :id => '3', :issue_status => {:name => ''} | |
83 | assert_response :success |
|
82 | assert_response :success | |
84 | assert_template 'edit' |
|
|||
85 | assert_select_error /name cannot be blank/i |
|
83 | assert_select_error /name cannot be blank/i | |
86 | end |
|
84 | end | |
87 |
|
85 |
@@ -55,9 +55,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
55 | with_settings :default_language => "en" do |
|
55 | with_settings :default_language => "en" do | |
56 | get :index |
|
56 | get :index | |
57 | assert_response :success |
|
57 | assert_response :success | |
58 | assert_template 'index' |
|
|||
59 | assert_not_nil assigns(:issues) |
|
|||
60 | assert_nil assigns(:project) |
|
|||
61 |
|
58 | |||
62 | # links to visible issues |
|
59 | # links to visible issues | |
63 | assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/ |
|
60 | assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/ | |
@@ -74,9 +71,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
74 | EnabledModule.where("name = 'issue_tracking' AND project_id = 1").delete_all |
|
71 | EnabledModule.where("name = 'issue_tracking' AND project_id = 1").delete_all | |
75 | get :index |
|
72 | get :index | |
76 | assert_response :success |
|
73 | assert_response :success | |
77 | assert_template 'index' |
|
|||
78 | assert_not_nil assigns(:issues) |
|
|||
79 | assert_nil assigns(:project) |
|
|||
80 |
|
74 | |||
81 | assert_select 'a[href="/issues/1"]', 0 |
|
75 | assert_select 'a[href="/issues/1"]', 0 | |
82 | assert_select 'a[href="/issues/5"]', :text => /Subproject issue/ |
|
76 | assert_select 'a[href="/issues/5"]', :text => /Subproject issue/ | |
@@ -85,16 +79,16 class IssuesControllerTest < Redmine::ControllerTest | |||||
85 | def test_index_should_list_visible_issues_only |
|
79 | def test_index_should_list_visible_issues_only | |
86 | get :index, :per_page => 100 |
|
80 | get :index, :per_page => 100 | |
87 | assert_response :success |
|
81 | assert_response :success | |
88 | assert_not_nil assigns(:issues) |
|
82 | ||
89 | assert_nil assigns(:issues).detect {|issue| !issue.visible?} |
|
83 | Issue.open.each do |issue| | |
|
84 | assert_select "tr#issue-#{issue.id}", issue.visible? ? 1 : 0 | |||
|
85 | end | |||
90 | end |
|
86 | end | |
91 |
|
87 | |||
92 | def test_index_with_project |
|
88 | def test_index_with_project | |
93 | Setting.display_subprojects_issues = 0 |
|
89 | Setting.display_subprojects_issues = 0 | |
94 | get :index, :project_id => 1 |
|
90 | get :index, :project_id => 1 | |
95 | assert_response :success |
|
91 | assert_response :success | |
96 | assert_template 'index' |
|
|||
97 | assert_not_nil assigns(:issues) |
|
|||
98 |
|
92 | |||
99 | assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/ |
|
93 | assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/ | |
100 | assert_select 'a[href="/issues/5"]', 0 |
|
94 | assert_select 'a[href="/issues/5"]', 0 | |
@@ -104,8 +98,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
104 | Setting.display_subprojects_issues = 1 |
|
98 | Setting.display_subprojects_issues = 1 | |
105 | get :index, :project_id => 1 |
|
99 | get :index, :project_id => 1 | |
106 | assert_response :success |
|
100 | assert_response :success | |
107 | assert_template 'index' |
|
|||
108 | assert_not_nil assigns(:issues) |
|
|||
109 |
|
101 | |||
110 | assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/ |
|
102 | assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/ | |
111 | assert_select 'a[href="/issues/5"]', :text => /Subproject issue/ |
|
103 | assert_select 'a[href="/issues/5"]', :text => /Subproject issue/ | |
@@ -117,8 +109,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
117 | Setting.display_subprojects_issues = 1 |
|
109 | Setting.display_subprojects_issues = 1 | |
118 | get :index, :project_id => 1 |
|
110 | get :index, :project_id => 1 | |
119 | assert_response :success |
|
111 | assert_response :success | |
120 | assert_template 'index' |
|
|||
121 | assert_not_nil assigns(:issues) |
|
|||
122 |
|
112 | |||
123 | assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/ |
|
113 | assert_select 'a[href="/issues/1"]', :text => /Cannot print recipes/ | |
124 | assert_select 'a[href="/issues/5"]', :text => /Subproject issue/ |
|
114 | assert_select 'a[href="/issues/5"]', :text => /Subproject issue/ | |
@@ -128,13 +118,9 class IssuesControllerTest < Redmine::ControllerTest | |||||
128 | def test_index_with_project_and_default_filter |
|
118 | def test_index_with_project_and_default_filter | |
129 | get :index, :project_id => 1, :set_filter => 1 |
|
119 | get :index, :project_id => 1, :set_filter => 1 | |
130 | assert_response :success |
|
120 | assert_response :success | |
131 | assert_template 'index' |
|
|||
132 | assert_not_nil assigns(:issues) |
|
|||
133 |
|
121 | |||
134 | query = assigns(:query) |
|
|||
135 | assert_not_nil query |
|
|||
136 | # default filter |
|
122 | # default filter | |
137 | assert_equal({'status_id' => {:operator => 'o', :values => ['']}}, query.filters) |
|
123 | assert_query_filters [['status_id', 'o', '']] | |
138 | end |
|
124 | end | |
139 |
|
125 | |||
140 | def test_index_with_project_and_filter |
|
126 | def test_index_with_project_and_filter | |
@@ -143,12 +129,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
143 | :op => {'tracker_id' => '='}, |
|
129 | :op => {'tracker_id' => '='}, | |
144 | :v => {'tracker_id' => ['1']} |
|
130 | :v => {'tracker_id' => ['1']} | |
145 | assert_response :success |
|
131 | assert_response :success | |
146 | assert_template 'index' |
|
|||
147 | assert_not_nil assigns(:issues) |
|
|||
148 |
|
132 | |||
149 | query = assigns(:query) |
|
133 | assert_query_filters [['tracker_id', '=', '1']] | |
150 | assert_not_nil query |
|
|||
151 | assert_equal({'tracker_id' => {:operator => '=', :values => ['1']}}, query.filters) |
|
|||
152 | end |
|
134 | end | |
153 |
|
135 | |||
154 | def test_index_with_short_filters |
|
136 | def test_index_with_short_filters | |
@@ -208,15 +190,10 class IssuesControllerTest < Redmine::ControllerTest | |||||
208 | expression_and_expected.each do |filter_expression, expected| |
|
190 | expression_and_expected.each do |filter_expression, expected| | |
209 |
|
191 | |||
210 | get :index, :set_filter => 1, field => filter_expression |
|
192 | get :index, :set_filter => 1, field => filter_expression | |
211 |
|
||||
212 | assert_response :success |
|
193 | assert_response :success | |
213 | assert_template 'index' |
|
|||
214 | assert_not_nil assigns(:issues) |
|
|||
215 |
|
194 | |||
216 | query = assigns(:query) |
|
195 | expected_with_default = default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}) | |
217 | assert_not_nil query |
|
196 | assert_query_filters expected_with_default.map {|f, v| [f, v[:operator], v[:values]]} | |
218 | assert query.has_filter?(field) |
|
|||
219 | assert_equal(default_filter.merge({field => {:operator => expected[:op], :values => expected[:values]}}), query.filters) |
|
|||
220 | end |
|
197 | end | |
221 | end |
|
198 | end | |
222 | end |
|
199 | end | |
@@ -224,13 +201,9 class IssuesControllerTest < Redmine::ControllerTest | |||||
224 | def test_index_with_project_and_empty_filters |
|
201 | def test_index_with_project_and_empty_filters | |
225 | get :index, :project_id => 1, :set_filter => 1, :fields => [''] |
|
202 | get :index, :project_id => 1, :set_filter => 1, :fields => [''] | |
226 | assert_response :success |
|
203 | assert_response :success | |
227 | assert_template 'index' |
|
|||
228 | assert_not_nil assigns(:issues) |
|
|||
229 |
|
204 | |||
230 | query = assigns(:query) |
|
|||
231 | assert_not_nil query |
|
|||
232 | # no filter |
|
205 | # no filter | |
233 |
assert_ |
|
206 | assert_query_filters [] | |
234 | end |
|
207 | end | |
235 |
|
208 | |||
236 | def test_index_with_project_custom_field_filter |
|
209 | def test_index_with_project_custom_field_filter | |
@@ -243,58 +216,46 class IssuesControllerTest < Redmine::ControllerTest | |||||
243 | get :index, :set_filter => 1, |
|
216 | get :index, :set_filter => 1, | |
244 | :f => [filter_name], |
|
217 | :f => [filter_name], | |
245 | :op => {filter_name => '='}, |
|
218 | :op => {filter_name => '='}, | |
246 | :v => {filter_name => ['Foo']} |
|
219 | :v => {filter_name => ['Foo']}, | |
|
220 | :c => ['project'] | |||
247 | assert_response :success |
|
221 | assert_response :success | |
248 | assert_template 'index' |
|
222 | ||
249 |
assert_equal [3, 5], |
|
223 | assert_equal [3, 5], issues_in_list.map(&:project_id).uniq.sort | |
250 | end |
|
224 | end | |
251 |
|
225 | |||
252 | def test_index_with_query |
|
226 | def test_index_with_query | |
253 | get :index, :project_id => 1, :query_id => 5 |
|
227 | get :index, :project_id => 1, :query_id => 5 | |
254 | assert_response :success |
|
228 | assert_response :success | |
255 | assert_template 'index' |
|
|||
256 | assert_not_nil assigns(:issues) |
|
|||
257 | assert_nil assigns(:issue_count_by_group) |
|
|||
258 | end |
|
229 | end | |
259 |
|
230 | |||
260 | def test_index_with_query_grouped_by_tracker |
|
231 | def test_index_with_query_grouped_by_tracker | |
261 | get :index, :project_id => 1, :query_id => 6 |
|
232 | get :index, :project_id => 1, :query_id => 6 | |
262 | assert_response :success |
|
233 | assert_response :success | |
263 | assert_template 'index' |
|
234 | assert_select 'tr.group span.count' | |
264 | assert_not_nil assigns(:issues) |
|
|||
265 | assert_not_nil assigns(:issue_count_by_group) |
|
|||
266 | end |
|
235 | end | |
267 |
|
236 | |||
268 | def test_index_with_query_grouped_and_sorted_by_category |
|
237 | def test_index_with_query_grouped_and_sorted_by_category | |
269 | get :index, :project_id => 1, :set_filter => 1, :group_by => "category", :sort => "category" |
|
238 | get :index, :project_id => 1, :set_filter => 1, :group_by => "category", :sort => "category" | |
270 | assert_response :success |
|
239 | assert_response :success | |
271 | assert_template 'index' |
|
240 | assert_select 'tr.group span.count' | |
272 | assert_not_nil assigns(:issues) |
|
|||
273 | assert_not_nil assigns(:issue_count_by_group) |
|
|||
274 | end |
|
241 | end | |
275 |
|
242 | |||
276 | def test_index_with_query_grouped_and_sorted_by_fixed_version |
|
243 | def test_index_with_query_grouped_and_sorted_by_fixed_version | |
277 | get :index, :project_id => 1, :set_filter => 1, :group_by => "fixed_version", :sort => "fixed_version" |
|
244 | get :index, :project_id => 1, :set_filter => 1, :group_by => "fixed_version", :sort => "fixed_version" | |
278 | assert_response :success |
|
245 | assert_response :success | |
279 | assert_template 'index' |
|
246 | assert_select 'tr.group span.count' | |
280 | assert_not_nil assigns(:issues) |
|
|||
281 | assert_not_nil assigns(:issue_count_by_group) |
|
|||
282 | end |
|
247 | end | |
283 |
|
248 | |||
284 | def test_index_with_query_grouped_and_sorted_by_fixed_version_in_reverse_order |
|
249 | def test_index_with_query_grouped_and_sorted_by_fixed_version_in_reverse_order | |
285 | get :index, :project_id => 1, :set_filter => 1, :group_by => "fixed_version", :sort => "fixed_version:desc" |
|
250 | get :index, :project_id => 1, :set_filter => 1, :group_by => "fixed_version", :sort => "fixed_version:desc" | |
286 | assert_response :success |
|
251 | assert_response :success | |
287 | assert_template 'index' |
|
252 | assert_select 'tr.group span.count' | |
288 | assert_not_nil assigns(:issues) |
|
|||
289 | assert_not_nil assigns(:issue_count_by_group) |
|
|||
290 | end |
|
253 | end | |
291 |
|
254 | |||
292 | def test_index_with_query_grouped_by_list_custom_field |
|
255 | def test_index_with_query_grouped_by_list_custom_field | |
293 | get :index, :project_id => 1, :query_id => 9 |
|
256 | get :index, :project_id => 1, :query_id => 9 | |
294 | assert_response :success |
|
257 | assert_response :success | |
295 | assert_template 'index' |
|
258 | assert_select 'tr.group span.count' | |
296 | assert_not_nil assigns(:issues) |
|
|||
297 | assert_not_nil assigns(:issue_count_by_group) |
|
|||
298 | end |
|
259 | end | |
299 |
|
260 | |||
300 | def test_index_with_query_grouped_by_key_value_custom_field |
|
261 | def test_index_with_query_grouped_by_key_value_custom_field | |
@@ -308,9 +269,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
308 |
|
269 | |||
309 | get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}" |
|
270 | get :index, :project_id => 1, :set_filter => 1, :group_by => "cf_#{cf.id}" | |
310 | assert_response :success |
|
271 | assert_response :success | |
311 | assert_template 'index' |
|
|||
312 | assert_not_nil assigns(:issues) |
|
|||
313 | assert_not_nil assigns(:issue_count_by_group) |
|
|||
314 |
|
272 | |||
315 | assert_select 'tr.group', 3 |
|
273 | assert_select 'tr.group', 3 | |
316 | assert_select 'tr.group' do |
|
274 | assert_select 'tr.group' do | |
@@ -369,9 +327,9 class IssuesControllerTest < Redmine::ControllerTest | |||||
369 | with_settings :default_language => 'en' do |
|
327 | with_settings :default_language => 'en' do | |
370 | get :index, :project_id => 1, :set_filter => 1, "cf_#{cf.id}" => "*", :group_by => "cf_#{cf.id}" |
|
328 | get :index, :project_id => 1, :set_filter => 1, "cf_#{cf.id}" => "*", :group_by => "cf_#{cf.id}" | |
371 | assert_response :success |
|
329 | assert_response :success | |
372 | assert_equal [1, 2], assigns(:issues).map(&:id).sort |
|
|||
373 | end |
|
330 | end | |
374 |
|
331 | |||
|
332 | assert_equal [1, 2], issues_in_list.map(&:id).sort | |||
375 | assert_select 'tr.group', 1 |
|
333 | assert_select 'tr.group', 1 | |
376 | assert_select 'tr.group', :text => /No/ |
|
334 | assert_select 'tr.group', :text => /No/ | |
377 | end |
|
335 | end | |
@@ -382,8 +340,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
382 | get :index, :set_filter => 1, :group_by => 'tracker', :sort => 'id:desc' |
|
340 | get :index, :set_filter => 1, :group_by => 'tracker', :sort => 'id:desc' | |
383 | assert_response :success |
|
341 | assert_response :success | |
384 |
|
342 | |||
385 | trackers = assigns(:issues).map(&:tracker).uniq |
|
343 | assert_equal ["Bug", "Feature request", "Support request"], | |
386 | assert_equal [1, 2, 3], trackers.map(&:id) |
|
344 | css_select("tr.issue td.tracker").map(&:text).uniq | |
387 | end |
|
345 | end | |
388 |
|
346 | |||
389 | def test_index_with_query_grouped_by_tracker_in_reverse_order |
|
347 | def test_index_with_query_grouped_by_tracker_in_reverse_order | |
@@ -392,8 +350,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
392 | get :index, :set_filter => 1, :group_by => 'tracker', :sort => 'id:desc,tracker:desc' |
|
350 | get :index, :set_filter => 1, :group_by => 'tracker', :sort => 'id:desc,tracker:desc' | |
393 | assert_response :success |
|
351 | assert_response :success | |
394 |
|
352 | |||
395 | trackers = assigns(:issues).map(&:tracker).uniq |
|
353 | assert_equal ["Bug", "Feature request", "Support request"].reverse, | |
396 | assert_equal [3, 2, 1], trackers.map(&:id) |
|
354 | css_select("tr.issue td.tracker").map(&:text).uniq | |
397 | end |
|
355 | end | |
398 |
|
356 | |||
399 | def test_index_with_query_id_and_project_id_should_set_session_query |
|
357 | def test_index_with_query_id_and_project_id_should_set_session_query | |
@@ -410,17 +368,16 class IssuesControllerTest < Redmine::ControllerTest | |||||
410 | end |
|
368 | end | |
411 |
|
369 | |||
412 | def test_index_with_cross_project_query_in_session_should_show_project_issues |
|
370 | def test_index_with_cross_project_query_in_session_should_show_project_issues | |
413 |
q = IssueQuery.create!(:name => " |
|
371 | q = IssueQuery.create!(:name => "cross_project_query", :user_id => 2, :project => nil, :column_names => ['project']) | |
414 | @request.session[:issue_query] = {:id => q.id, :project_id => 1} |
|
372 | @request.session[:issue_query] = {:id => q.id, :project_id => 1} | |
415 |
|
373 | |||
416 | with_settings :display_subprojects_issues => '0' do |
|
374 | with_settings :display_subprojects_issues => '0' do | |
417 | get :index, :project_id => 1 |
|
375 | get :index, :project_id => 1 | |
418 | end |
|
376 | end | |
419 | assert_response :success |
|
377 | assert_response :success | |
420 | assert_not_nil assigns(:query) |
|
378 | ||
421 | assert_equal q.id, assigns(:query).id |
|
379 | assert_select 'h2', :text => q.name | |
422 | assert_equal 1, assigns(:query).project_id |
|
380 | assert_equal ["eCookbook"], css_select("tr.issue td.project").map(&:text).uniq | |
423 | assert_equal [1], assigns(:issues).map(&:project_id).uniq |
|
|||
424 | end |
|
381 | end | |
425 |
|
382 | |||
426 | def test_private_query_should_not_be_available_to_other_users |
|
383 | def test_private_query_should_not_be_available_to_other_users | |
@@ -496,17 +453,18 class IssuesControllerTest < Redmine::ControllerTest | |||||
496 | def test_index_csv |
|
453 | def test_index_csv | |
497 | get :index, :format => 'csv' |
|
454 | get :index, :format => 'csv' | |
498 | assert_response :success |
|
455 | assert_response :success | |
499 | assert_not_nil assigns(:issues) |
|
456 | ||
500 | assert_equal 'text/csv; header=present', @response.content_type |
|
457 | assert_equal 'text/csv; header=present', @response.content_type | |
501 |
assert |
|
458 | assert response.body.starts_with?("#,") | |
502 |
lines = |
|
459 | lines = response.body.chomp.split("\n") | |
503 | assert_equal assigns(:query).columns.size, lines[0].split(',').size |
|
460 | # default columns + id and project | |
|
461 | assert_equal Setting.issue_list_default_columns.size + 2, lines[0].split(',').size | |||
504 | end |
|
462 | end | |
505 |
|
463 | |||
506 | def test_index_csv_with_project |
|
464 | def test_index_csv_with_project | |
507 | get :index, :project_id => 1, :format => 'csv' |
|
465 | get :index, :project_id => 1, :format => 'csv' | |
508 | assert_response :success |
|
466 | assert_response :success | |
509 | assert_not_nil assigns(:issues) |
|
467 | ||
510 | assert_equal 'text/csv; header=present', @response.content_type |
|
468 | assert_equal 'text/csv; header=present', @response.content_type | |
511 | end |
|
469 | end | |
512 |
|
470 | |||
@@ -515,7 +473,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
515 | Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 5, :subject => 'Closed issue', :author_id => 1) |
|
473 | Issue.create!(:project_id => 1, :tracker_id => 1, :status_id => 5, :subject => 'Closed issue', :author_id => 1) | |
516 | get :index, :set_filter => 1, :f => [], :format => 'csv' |
|
474 | get :index, :set_filter => 1, :f => [], :format => 'csv' | |
517 | assert_response :success |
|
475 | assert_response :success | |
518 | assert_equal Issue.count, assigns(:issues).count |
|
476 | # -1 for headers | |
|
477 | assert_equal Issue.count, response.body.chomp.split("\n").size - 1 | |||
519 | end |
|
478 | end | |
520 |
|
479 | |||
521 | def test_index_csv_with_description |
|
480 | def test_index_csv_with_description | |
@@ -524,7 +483,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
524 | with_settings :default_language => 'en' do |
|
483 | with_settings :default_language => 'en' do | |
525 | get :index, :format => 'csv', :csv => {:description => '1'} |
|
484 | get :index, :format => 'csv', :csv => {:description => '1'} | |
526 | assert_response :success |
|
485 | assert_response :success | |
527 | assert_not_nil assigns(:issues) |
|
|||
528 | end |
|
486 | end | |
529 |
|
487 | |||
530 | assert_equal 'text/csv; header=present', response.content_type |
|
488 | assert_equal 'text/csv; header=present', response.content_type | |
@@ -547,11 +505,11 class IssuesControllerTest < Redmine::ControllerTest | |||||
547 | def test_index_csv_with_all_columns |
|
505 | def test_index_csv_with_all_columns | |
548 | get :index, :format => 'csv', :csv => {:columns => 'all'} |
|
506 | get :index, :format => 'csv', :csv => {:columns => 'all'} | |
549 | assert_response :success |
|
507 | assert_response :success | |
550 | assert_not_nil assigns(:issues) |
|
508 | ||
551 | assert_equal 'text/csv; header=present', @response.content_type |
|
509 | assert_equal 'text/csv; header=present', @response.content_type | |
552 | assert_match /\A#,/, response.body |
|
510 | assert_match /\A#,/, response.body | |
553 | lines = response.body.chomp.split("\n") |
|
511 | lines = response.body.chomp.split("\n") | |
554 |
assert_equal |
|
512 | assert_equal IssueQuery.new.available_inline_columns.size, lines[0].split(',').size | |
555 | end |
|
513 | end | |
556 |
|
514 | |||
557 | def test_index_csv_with_multi_column_field |
|
515 | def test_index_csv_with_multi_column_field | |
@@ -680,21 +638,17 class IssuesControllerTest < Redmine::ControllerTest | |||||
680 |
|
638 | |||
681 | get :index |
|
639 | get :index | |
682 | assert_response :success |
|
640 | assert_response :success | |
683 | assert_template 'index' |
|
|||
684 |
|
641 | |||
685 | get :index, :format => 'pdf' |
|
642 | get :index, :format => 'pdf' | |
686 | assert_response :success |
|
643 | assert_response :success | |
687 | assert_not_nil assigns(:issues) |
|
|||
688 | assert_equal 'application/pdf', @response.content_type |
|
644 | assert_equal 'application/pdf', @response.content_type | |
689 |
|
645 | |||
690 | get :index, :project_id => 1, :format => 'pdf' |
|
646 | get :index, :project_id => 1, :format => 'pdf' | |
691 | assert_response :success |
|
647 | assert_response :success | |
692 | assert_not_nil assigns(:issues) |
|
|||
693 | assert_equal 'application/pdf', @response.content_type |
|
648 | assert_equal 'application/pdf', @response.content_type | |
694 |
|
649 | |||
695 | get :index, :project_id => 1, :query_id => 6, :format => 'pdf' |
|
650 | get :index, :project_id => 1, :query_id => 6, :format => 'pdf' | |
696 | assert_response :success |
|
651 | assert_response :success | |
697 | assert_not_nil assigns(:issues) |
|
|||
698 | assert_equal 'application/pdf', @response.content_type |
|
652 | assert_equal 'application/pdf', @response.content_type | |
699 | end |
|
653 | end | |
700 | end |
|
654 | end | |
@@ -703,15 +657,12 class IssuesControllerTest < Redmine::ControllerTest | |||||
703 | def test_index_pdf_with_query_grouped_by_list_custom_field |
|
657 | def test_index_pdf_with_query_grouped_by_list_custom_field | |
704 | get :index, :project_id => 1, :query_id => 9, :format => 'pdf' |
|
658 | get :index, :project_id => 1, :query_id => 9, :format => 'pdf' | |
705 | assert_response :success |
|
659 | assert_response :success | |
706 | assert_not_nil assigns(:issues) |
|
|||
707 | assert_not_nil assigns(:issue_count_by_group) |
|
|||
708 | assert_equal 'application/pdf', @response.content_type |
|
660 | assert_equal 'application/pdf', @response.content_type | |
709 | end |
|
661 | end | |
710 |
|
662 | |||
711 | def test_index_atom |
|
663 | def test_index_atom | |
712 | get :index, :project_id => 'ecookbook', :format => 'atom' |
|
664 | get :index, :project_id => 'ecookbook', :format => 'atom' | |
713 | assert_response :success |
|
665 | assert_response :success | |
714 | assert_template 'common/feed' |
|
|||
715 | assert_equal 'application/atom+xml', response.content_type |
|
666 | assert_equal 'application/atom+xml', response.content_type | |
716 |
|
667 | |||
717 | assert_select 'feed' do |
|
668 | assert_select 'feed' do | |
@@ -735,10 +686,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
735 | assert sort_params.is_a?(String) |
|
686 | assert sort_params.is_a?(String) | |
736 | assert_equal 'tracker,id:desc', sort_params |
|
687 | assert_equal 'tracker,id:desc', sort_params | |
737 |
|
688 | |||
738 | issues = assigns(:issues) |
|
689 | assert_equal issues_in_list.sort_by {|issue| [issue.tracker.position, -issue.id]}, issues_in_list | |
739 | assert_not_nil issues |
|
|||
740 | assert !issues.empty? |
|
|||
741 | assert_equal issues.sort {|a,b| a.tracker == b.tracker ? b.id <=> a.id : a.tracker <=> b.tracker }.collect(&:id), issues.collect(&:id) |
|
|||
742 | assert_select 'table.issues.sort-by-tracker.sort-asc' |
|
690 | assert_select 'table.issues.sort-by-tracker.sort-asc' | |
743 | end |
|
691 | end | |
744 |
|
692 | |||
@@ -750,7 +698,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
750 | def test_index_sort_by_assigned_to |
|
698 | def test_index_sort_by_assigned_to | |
751 | get :index, :sort => 'assigned_to' |
|
699 | get :index, :sort => 'assigned_to' | |
752 | assert_response :success |
|
700 | assert_response :success | |
753 | assignees = assigns(:issues).collect(&:assigned_to).compact |
|
701 | ||
|
702 | assignees = issues_in_list.map(&:assigned_to).compact | |||
754 | assert_equal assignees.sort, assignees |
|
703 | assert_equal assignees.sort, assignees | |
755 | assert_select 'table.issues.sort-by-assigned-to.sort-asc' |
|
704 | assert_select 'table.issues.sort-by-assigned-to.sort-asc' | |
756 | end |
|
705 | end | |
@@ -758,7 +707,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
758 | def test_index_sort_by_assigned_to_desc |
|
707 | def test_index_sort_by_assigned_to_desc | |
759 | get :index, :sort => 'assigned_to:desc' |
|
708 | get :index, :sort => 'assigned_to:desc' | |
760 | assert_response :success |
|
709 | assert_response :success | |
761 | assignees = assigns(:issues).collect(&:assigned_to).compact |
|
710 | ||
|
711 | assignees = issues_in_list.map(&:assigned_to).compact | |||
762 | assert_equal assignees.sort.reverse, assignees |
|
712 | assert_equal assignees.sort.reverse, assignees | |
763 | assert_select 'table.issues.sort-by-assigned-to.sort-desc' |
|
713 | assert_select 'table.issues.sort-by-assigned-to.sort-desc' | |
764 | end |
|
714 | end | |
@@ -769,16 +719,18 class IssuesControllerTest < Redmine::ControllerTest | |||||
769 | end |
|
719 | end | |
770 |
|
720 | |||
771 | def test_index_sort_by_author |
|
721 | def test_index_sort_by_author | |
772 | get :index, :sort => 'author' |
|
722 | get :index, :sort => 'author', :c => ['author'] | |
773 | assert_response :success |
|
723 | assert_response :success | |
774 | authors = assigns(:issues).collect(&:author) |
|
724 | ||
|
725 | authors = issues_in_list.map(&:author) | |||
775 | assert_equal authors.sort, authors |
|
726 | assert_equal authors.sort, authors | |
776 | end |
|
727 | end | |
777 |
|
728 | |||
778 | def test_index_sort_by_author_desc |
|
729 | def test_index_sort_by_author_desc | |
779 | get :index, :sort => 'author:desc' |
|
730 | get :index, :sort => 'author:desc' | |
780 | assert_response :success |
|
731 | assert_response :success | |
781 | authors = assigns(:issues).collect(&:author) |
|
732 | ||
|
733 | authors = issues_in_list.map(&:author) | |||
782 | assert_equal authors.sort.reverse, authors |
|
734 | assert_equal authors.sort.reverse, authors | |
783 | end |
|
735 | end | |
784 |
|
736 | |||
@@ -790,21 +742,21 class IssuesControllerTest < Redmine::ControllerTest | |||||
790 | def test_index_sort_by_spent_hours |
|
742 | def test_index_sort_by_spent_hours | |
791 | get :index, :sort => 'spent_hours:desc' |
|
743 | get :index, :sort => 'spent_hours:desc' | |
792 | assert_response :success |
|
744 | assert_response :success | |
793 |
hours = |
|
745 | hours = issues_in_list.map(&:spent_hours) | |
794 | assert_equal hours.sort.reverse, hours |
|
746 | assert_equal hours.sort.reverse, hours | |
795 | end |
|
747 | end | |
796 |
|
748 | |||
797 | def test_index_sort_by_total_spent_hours |
|
749 | def test_index_sort_by_total_spent_hours | |
798 | get :index, :sort => 'total_spent_hours:desc' |
|
750 | get :index, :sort => 'total_spent_hours:desc' | |
799 | assert_response :success |
|
751 | assert_response :success | |
800 |
hours = |
|
752 | hours = issues_in_list.map(&:total_spent_hours) | |
801 | assert_equal hours.sort.reverse, hours |
|
753 | assert_equal hours.sort.reverse, hours | |
802 | end |
|
754 | end | |
803 |
|
755 | |||
804 | def test_index_sort_by_total_estimated_hours |
|
756 | def test_index_sort_by_total_estimated_hours | |
805 | get :index, :sort => 'total_estimated_hours:desc' |
|
757 | get :index, :sort => 'total_estimated_hours:desc' | |
806 | assert_response :success |
|
758 | assert_response :success | |
807 |
hours = |
|
759 | hours = issues_in_list.map(&:total_estimated_hours) | |
808 | assert_equal hours.sort.reverse, hours |
|
760 | assert_equal hours.sort.reverse, hours | |
809 | end |
|
761 | end | |
810 |
|
762 | |||
@@ -818,7 +770,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
818 | get :index, :project_id => 1, :set_filter => 1, :sort => "cf_#{cf.id},id" |
|
770 | get :index, :project_id => 1, :set_filter => 1, :sort => "cf_#{cf.id},id" | |
819 | assert_response :success |
|
771 | assert_response :success | |
820 |
|
772 | |||
821 |
assert_equal [2, 3, 1], |
|
773 | assert_equal [2, 3, 1], issues_in_list.select {|issue| issue.custom_field_value(cf).present?}.map(&:id) | |
822 | end |
|
774 | end | |
823 |
|
775 | |||
824 | def test_index_with_columns |
|
776 | def test_index_with_columns | |
@@ -826,10 +778,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
826 | get :index, :set_filter => 1, :c => columns |
|
778 | get :index, :set_filter => 1, :c => columns | |
827 | assert_response :success |
|
779 | assert_response :success | |
828 |
|
780 | |||
829 | # query should use specified columns |
|
781 | # query should use specified columns + id and checkbox | |
830 | query = assigns(:query) |
|
782 | assert_select 'table.issues thead th', columns.size + 2 | |
831 | assert_kind_of IssueQuery, query |
|
|||
832 | assert_equal columns, query.column_names.map(&:to_s) |
|
|||
833 |
|
783 | |||
834 | # columns should be stored in session |
|
784 | # columns should be stored in session | |
835 | assert_kind_of Hash, session[:issue_query] |
|
785 | assert_kind_of Hash, session[:issue_query] | |
@@ -849,9 +799,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
849 | get :index, :set_filter => 1 |
|
799 | get :index, :set_filter => 1 | |
850 |
|
800 | |||
851 | # query should use specified columns |
|
801 | # query should use specified columns | |
852 | query = assigns(:query) |
|
802 | assert_equal ["#", "Project", "Tracker", "Subject", "Assignee"], columns_in_issues_list | |
853 | assert_kind_of IssueQuery, query |
|
|||
854 | assert_equal [:id, :project, :tracker, :subject, :assigned_to], query.columns.map(&:name) |
|
|||
855 | end |
|
803 | end | |
856 |
|
804 | |||
857 | def test_index_without_project_and_explicit_default_columns_should_not_add_project_column |
|
805 | def test_index_without_project_and_explicit_default_columns_should_not_add_project_column | |
@@ -860,9 +808,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
860 | get :index, :set_filter => 1, :c => columns |
|
808 | get :index, :set_filter => 1, :c => columns | |
861 |
|
809 | |||
862 | # query should use specified columns |
|
810 | # query should use specified columns | |
863 | query = assigns(:query) |
|
811 | assert_equal ["#", "Tracker", "Subject", "Assignee"], columns_in_issues_list | |
864 | assert_kind_of IssueQuery, query |
|
|||
865 | assert_equal columns.map(&:to_sym), query.columns.map(&:name) |
|
|||
866 | end |
|
812 | end | |
867 |
|
813 | |||
868 | def test_index_with_default_columns_should_respect_default_columns_order |
|
814 | def test_index_with_default_columns_should_respect_default_columns_order | |
@@ -870,8 +816,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
870 | with_settings :issue_list_default_columns => columns do |
|
816 | with_settings :issue_list_default_columns => columns do | |
871 | get :index, :project_id => 1, :set_filter => 1 |
|
817 | get :index, :project_id => 1, :set_filter => 1 | |
872 |
|
818 | |||
873 | query = assigns(:query) |
|
819 | assert_equal ["#", "Assignee", "Subject", "Status", "Tracker"], columns_in_issues_list | |
874 | assert_equal (['id'] + columns).map(&:to_sym), query.columns.map(&:name) |
|
|||
875 | end |
|
820 | end | |
876 | end |
|
821 | end | |
877 |
|
822 | |||
@@ -881,10 +826,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
881 | assert_response :success |
|
826 | assert_response :success | |
882 |
|
827 | |||
883 | # query should use specified columns |
|
828 | # query should use specified columns | |
884 | query = assigns(:query) |
|
829 | assert_equal ["#", "Tracker", "Subject", "Searchable field"], columns_in_issues_list | |
885 | assert_kind_of IssueQuery, query |
|
|||
886 | assert_equal columns, query.column_names.map(&:to_s) |
|
|||
887 |
|
||||
888 | assert_select 'table.issues td.cf_2.string' |
|
830 | assert_select 'table.issues td.cf_2.string' | |
889 | end |
|
831 | end | |
890 |
|
832 | |||
@@ -1081,7 +1023,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
1081 | def test_index_send_html_if_query_is_invalid |
|
1023 | def test_index_send_html_if_query_is_invalid | |
1082 | get :index, :f => ['start_date'], :op => {:start_date => '='} |
|
1024 | get :index, :f => ['start_date'], :op => {:start_date => '='} | |
1083 | assert_equal 'text/html', @response.content_type |
|
1025 | assert_equal 'text/html', @response.content_type | |
1084 | assert_template 'index' |
|
1026 | assert_select_error /Start date cannot be blank/i | |
1085 | end |
|
1027 | end | |
1086 |
|
1028 | |||
1087 | def test_index_send_nothing_if_query_is_invalid |
|
1029 | def test_index_send_nothing_if_query_is_invalid | |
@@ -1169,8 +1111,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
1169 | def test_show_by_anonymous |
|
1111 | def test_show_by_anonymous | |
1170 | get :show, :id => 1 |
|
1112 | get :show, :id => 1 | |
1171 | assert_response :success |
|
1113 | assert_response :success | |
1172 | assert_template 'show' |
|
1114 | ||
1173 | assert_equal Issue.find(1), assigns(:issue) |
|
|||
1174 | assert_select 'div.issue div.description', :text => /Unable to print recipes/ |
|
1115 | assert_select 'div.issue div.description', :text => /Unable to print recipes/ | |
1175 | # anonymous role is allowed to add a note |
|
1116 | # anonymous role is allowed to add a note | |
1176 | assert_select 'form#issue-form' do |
|
1117 | assert_select 'form#issue-form' do | |
@@ -1185,7 +1126,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
1185 | def test_show_by_manager |
|
1126 | def test_show_by_manager | |
1186 | @request.session[:user_id] = 2 |
|
1127 | @request.session[:user_id] = 2 | |
1187 | get :show, :id => 1 |
|
1128 | get :show, :id => 1 | |
1188 | assert_response :success |
|
1129 | ||
1189 | assert_select 'a', :text => /Quote/ |
|
1130 | assert_select 'a', :text => /Quote/ | |
1190 | assert_select 'form#issue-form' do |
|
1131 | assert_select 'form#issue-form' do | |
1191 | assert_select 'fieldset' do |
|
1132 | assert_select 'fieldset' do | |
@@ -1395,8 +1336,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1395 | def test_show_should_not_display_prev_next_links_without_query_in_session |
|
1336 | def test_show_should_not_display_prev_next_links_without_query_in_session | |
1396 | get :show, :id => 1 |
|
1337 | get :show, :id => 1 | |
1397 | assert_response :success |
|
1338 | assert_response :success | |
1398 | assert_nil assigns(:prev_issue_id) |
|
|||
1399 | assert_nil assigns(:next_issue_id) |
|
|||
1400 |
|
1339 | |||
1401 | assert_select 'div.next-prev-links', 0 |
|
1340 | assert_select 'div.next-prev-links', 0 | |
1402 | end |
|
1341 | end | |
@@ -1408,14 +1347,11 class IssuesControllerTest < Redmine::ControllerTest | |||||
1408 | with_settings :display_subprojects_issues => '0' do |
|
1347 | with_settings :display_subprojects_issues => '0' do | |
1409 | get :show, :id => 3 |
|
1348 | get :show, :id => 3 | |
1410 | end |
|
1349 | end | |
1411 |
|
||||
1412 | assert_response :success |
|
1350 | assert_response :success | |
1413 | # Previous and next issues for all projects |
|
|||
1414 | assert_equal 2, assigns(:prev_issue_id) |
|
|||
1415 | assert_equal 5, assigns(:next_issue_id) |
|
|||
1416 |
|
1351 | |||
1417 | count = Issue.open.visible.count |
|
1352 | count = Issue.open.visible.count | |
1418 |
|
1353 | |||
|
1354 | # Previous and next issues for all projects | |||
1419 | assert_select 'div.next-prev-links' do |
|
1355 | assert_select 'div.next-prev-links' do | |
1420 | assert_select 'a[href="/issues/2"]', :text => /Previous/ |
|
1356 | assert_select 'a[href="/issues/2"]', :text => /Previous/ | |
1421 | assert_select 'a[href="/issues/5"]', :text => /Next/ |
|
1357 | assert_select 'a[href="/issues/5"]', :text => /Next/ | |
@@ -1430,13 +1366,9 class IssuesControllerTest < Redmine::ControllerTest | |||||
1430 | @request.session[:query] = {:id => query.id, :project_id => nil} |
|
1366 | @request.session[:query] = {:id => query.id, :project_id => nil} | |
1431 |
|
1367 | |||
1432 | get :show, :id => 11 |
|
1368 | get :show, :id => 11 | |
1433 |
|
||||
1434 | assert_response :success |
|
1369 | assert_response :success | |
1435 | assert_equal query, assigns(:query) |
|
|||
1436 | # Previous and next issues for all projects |
|
|||
1437 | assert_equal 8, assigns(:prev_issue_id) |
|
|||
1438 | assert_equal 12, assigns(:next_issue_id) |
|
|||
1439 |
|
1370 | |||
|
1371 | # Previous and next issues for all projects | |||
1440 | assert_select 'div.next-prev-links' do |
|
1372 | assert_select 'div.next-prev-links' do | |
1441 | assert_select 'a[href="/issues/8"]', :text => /Previous/ |
|
1373 | assert_select 'a[href="/issues/8"]', :text => /Previous/ | |
1442 | assert_select 'a[href="/issues/12"]', :text => /Next/ |
|
1374 | assert_select 'a[href="/issues/12"]', :text => /Next/ | |
@@ -1465,12 +1397,9 class IssuesControllerTest < Redmine::ControllerTest | |||||
1465 | with_settings :display_subprojects_issues => '0' do |
|
1397 | with_settings :display_subprojects_issues => '0' do | |
1466 | get :show, :id => 3 |
|
1398 | get :show, :id => 3 | |
1467 | end |
|
1399 | end | |
1468 |
|
||||
1469 | assert_response :success |
|
1400 | assert_response :success | |
1470 | # Previous and next issues inside project |
|
|||
1471 | assert_equal 2, assigns(:prev_issue_id) |
|
|||
1472 | assert_equal 7, assigns(:next_issue_id) |
|
|||
1473 |
|
1401 | |||
|
1402 | # Previous and next issues inside project | |||
1474 | assert_select 'div.next-prev-links' do |
|
1403 | assert_select 'div.next-prev-links' do | |
1475 | assert_select 'a[href="/issues/2"]', :text => /Previous/ |
|
1404 | assert_select 'a[href="/issues/2"]', :text => /Previous/ | |
1476 | assert_select 'a[href="/issues/7"]', :text => /Next/ |
|
1405 | assert_select 'a[href="/issues/7"]', :text => /Next/ | |
@@ -1484,10 +1413,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
1484 | with_settings :display_subprojects_issues => '0' do |
|
1413 | with_settings :display_subprojects_issues => '0' do | |
1485 | get :show, :id => 1 |
|
1414 | get :show, :id => 1 | |
1486 | end |
|
1415 | end | |
1487 |
|
||||
1488 | assert_response :success |
|
1416 | assert_response :success | |
1489 | assert_nil assigns(:prev_issue_id) |
|
|||
1490 | assert_equal 2, assigns(:next_issue_id) |
|
|||
1491 |
|
1417 | |||
1492 | assert_select 'div.next-prev-links' do |
|
1418 | assert_select 'div.next-prev-links' do | |
1493 | assert_select 'a', :text => /Previous/, :count => 0 |
|
1419 | assert_select 'a', :text => /Previous/, :count => 0 | |
@@ -1500,10 +1426,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
1500 | @request.session['issues_index_sort'] = 'id' |
|
1426 | @request.session['issues_index_sort'] = 'id' | |
1501 |
|
1427 | |||
1502 | get :show, :id => 1 |
|
1428 | get :show, :id => 1 | |
1503 |
|
||||
1504 | assert_response :success |
|
1429 | assert_response :success | |
1505 | assert_nil assigns(:prev_issue_id) |
|
|||
1506 | assert_nil assigns(:next_issue_id) |
|
|||
1507 |
|
1430 | |||
1508 | assert_select 'a', :text => /Previous/, :count => 0 |
|
1431 | assert_select 'a', :text => /Previous/, :count => 0 | |
1509 | assert_select 'a', :text => /Next/, :count => 0 |
|
1432 | assert_select 'a', :text => /Next/, :count => 0 | |
@@ -1523,9 +1446,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1523 | get :show, :id => 3 |
|
1446 | get :show, :id => 3 | |
1524 | assert_response :success |
|
1447 | assert_response :success | |
1525 |
|
1448 | |||
1526 | assert_equal 2, assigns(:prev_issue_id) |
|
|||
1527 | assert_equal 1, assigns(:next_issue_id) |
|
|||
1528 |
|
||||
1529 | assert_select 'div.next-prev-links' do |
|
1449 | assert_select 'div.next-prev-links' do | |
1530 | assert_select 'a[href="/issues/2"]', :text => /Previous/ |
|
1450 | assert_select 'a[href="/issues/2"]', :text => /Previous/ | |
1531 | assert_select 'a[href="/issues/1"]', :text => /Next/ |
|
1451 | assert_select 'a[href="/issues/1"]', :text => /Next/ | |
@@ -1673,18 +1593,18 class IssuesControllerTest < Redmine::ControllerTest | |||||
1673 |
|
1593 | |||
1674 | get :show, :id => 2 |
|
1594 | get :show, :id => 2 | |
1675 | assert_response :success |
|
1595 | assert_response :success | |
1676 | assert_include journal, assigns(:journals) |
|
1596 | assert_select "#change-#{journal.id}", 1 | |
1677 |
|
1597 | |||
1678 | Role.find(1).remove_permission! :view_private_notes |
|
1598 | Role.find(1).remove_permission! :view_private_notes | |
1679 | get :show, :id => 2 |
|
1599 | get :show, :id => 2 | |
1680 | assert_response :success |
|
1600 | assert_response :success | |
1681 | assert_not_include journal, assigns(:journals) |
|
1601 | assert_select "#change-#{journal.id}", 0 | |
1682 | end |
|
1602 | end | |
1683 |
|
1603 | |||
1684 | def test_show_atom |
|
1604 | def test_show_atom | |
1685 | get :show, :id => 2, :format => 'atom' |
|
1605 | get :show, :id => 2, :format => 'atom' | |
1686 | assert_response :success |
|
1606 | assert_response :success | |
1687 | assert_template 'journals/index' |
|
1607 | assert_equal 'application/atom+xml', response.content_type | |
1688 | # Inline image |
|
1608 | # Inline image | |
1689 | assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10')) |
|
1609 | assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10')) | |
1690 | end |
|
1610 | end | |
@@ -1696,7 +1616,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1696 | assert_response :success |
|
1616 | assert_response :success | |
1697 | assert_equal 'application/pdf', @response.content_type |
|
1617 | assert_equal 'application/pdf', @response.content_type | |
1698 | assert @response.body.starts_with?('%PDF') |
|
1618 | assert @response.body.starts_with?('%PDF') | |
1699 | assert_not_nil assigns(:issue) |
|
|||
1700 | end |
|
1619 | end | |
1701 |
|
1620 | |||
1702 | def test_export_to_pdf_with_utf8_u_fffd |
|
1621 | def test_export_to_pdf_with_utf8_u_fffd | |
@@ -1710,7 +1629,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1710 | assert_response :success |
|
1629 | assert_response :success | |
1711 | assert_equal 'application/pdf', @response.content_type |
|
1630 | assert_equal 'application/pdf', @response.content_type | |
1712 | assert @response.body.starts_with?('%PDF') |
|
1631 | assert @response.body.starts_with?('%PDF') | |
1713 | assert_not_nil assigns(:issue) |
|
|||
1714 | end |
|
1632 | end | |
1715 | end |
|
1633 | end | |
1716 | end |
|
1634 | end | |
@@ -1765,7 +1683,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1765 | @request.session[:user_id] = 2 |
|
1683 | @request.session[:user_id] = 2 | |
1766 | get :new, :project_id => 1, :tracker_id => 1 |
|
1684 | get :new, :project_id => 1, :tracker_id => 1 | |
1767 | assert_response :success |
|
1685 | assert_response :success | |
1768 | assert_template 'new' |
|
|||
1769 |
|
1686 | |||
1770 | assert_select 'form#issue-form[action=?]', '/projects/ecookbook/issues' |
|
1687 | assert_select 'form#issue-form[action=?]', '/projects/ecookbook/issues' | |
1771 | assert_select 'form#issue-form' do |
|
1688 | assert_select 'form#issue-form' do | |
@@ -1801,7 +1718,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1801 | @request.session[:user_id] = 2 |
|
1718 | @request.session[:user_id] = 2 | |
1802 | get :new, :project_id => 1, :tracker_id => 1 |
|
1719 | get :new, :project_id => 1, :tracker_id => 1 | |
1803 | assert_response :success |
|
1720 | assert_response :success | |
1804 | assert_template 'new' |
|
|||
1805 |
|
1721 | |||
1806 | assert_select 'form#issue-form' do |
|
1722 | assert_select 'form#issue-form' do | |
1807 | assert_select 'input[name=?]', 'issue[is_private]', 0 |
|
1723 | assert_select 'input[name=?]', 'issue[is_private]', 0 | |
@@ -1827,15 +1743,11 class IssuesControllerTest < Redmine::ControllerTest | |||||
1827 | @request.session[:user_id] = 2 |
|
1743 | @request.session[:user_id] = 2 | |
1828 | get :new |
|
1744 | get :new | |
1829 | assert_response :success |
|
1745 | assert_response :success | |
1830 | assert_template 'new' |
|
|||
1831 |
|
1746 | |||
1832 | assert_select 'form#issue-form[action=?]', '/issues' |
|
1747 | assert_select 'form#issue-form[action=?]', '/issues' | |
1833 | assert_select 'form#issue-form' do |
|
1748 | assert_select 'form#issue-form' do | |
1834 | assert_select 'select[name=?]', 'issue[project_id]' |
|
1749 | assert_select 'select[name=?]', 'issue[project_id]' | |
1835 | end |
|
1750 | end | |
1836 |
|
||||
1837 | assert_nil assigns(:project) |
|
|||
1838 | assert_not_nil assigns(:issue) |
|
|||
1839 | end |
|
1751 | end | |
1840 |
|
1752 | |||
1841 | def test_new_should_select_default_status |
|
1753 | def test_new_should_select_default_status | |
@@ -1843,7 +1755,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1843 |
|
1755 | |||
1844 | get :new, :project_id => 1 |
|
1756 | get :new, :project_id => 1 | |
1845 | assert_response :success |
|
1757 | assert_response :success | |
1846 | assert_template 'new' |
|
|||
1847 | assert_select 'select[name=?]', 'issue[status_id]' do |
|
1758 | assert_select 'select[name=?]', 'issue[status_id]' do | |
1848 | assert_select 'option[value="1"][selected=selected]' |
|
1759 | assert_select 'option[value="1"][selected=selected]' | |
1849 | end |
|
1760 | end | |
@@ -1913,7 +1824,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1913 |
|
1824 | |||
1914 | get :new, :project_id => 1 |
|
1825 | get :new, :project_id => 1 | |
1915 | assert_response :success |
|
1826 | assert_response :success | |
1916 | assert_equal version, assigns(:issue).fixed_version |
|
|||
1917 | assert_select 'select[name=?]', 'issue[fixed_version_id]' do |
|
1827 | assert_select 'select[name=?]', 'issue[fixed_version_id]' do | |
1918 | assert_select 'option[value=?][selected=selected]', version.id.to_s |
|
1828 | assert_select 'option[value=?][selected=selected]', version.id.to_s | |
1919 | end |
|
1829 | end | |
@@ -1923,7 +1833,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1923 | @request.session[:user_id] = 2 |
|
1833 | @request.session[:user_id] = 2 | |
1924 | get :new, :project_id => 1, :tracker_id => 1 |
|
1834 | get :new, :project_id => 1, :tracker_id => 1 | |
1925 | assert_response :success |
|
1835 | assert_response :success | |
1926 | assert_template 'new' |
|
|||
1927 |
|
1836 | |||
1928 | assert_select 'select.list_cf[name=?]', 'issue[custom_field_values][1]' do |
|
1837 | assert_select 'select.list_cf[name=?]', 'issue[custom_field_values][1]' do | |
1929 | assert_select 'option', 4 |
|
1838 | assert_select 'option', 4 | |
@@ -1938,7 +1847,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1938 | @request.session[:user_id] = 2 |
|
1847 | @request.session[:user_id] = 2 | |
1939 | get :new, :project_id => 1, :tracker_id => 1 |
|
1848 | get :new, :project_id => 1, :tracker_id => 1 | |
1940 | assert_response :success |
|
1849 | assert_response :success | |
1941 | assert_template 'new' |
|
|||
1942 |
|
1850 | |||
1943 | assert_select 'select[name=?][multiple=multiple]', 'issue[custom_field_values][1][]' do |
|
1851 | assert_select 'select[name=?][multiple=multiple]', 'issue[custom_field_values][1][]' do | |
1944 | assert_select 'option', 3 |
|
1852 | assert_select 'option', 3 | |
@@ -1954,7 +1862,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1954 | @request.session[:user_id] = 2 |
|
1862 | @request.session[:user_id] = 2 | |
1955 | get :new, :project_id => 1, :tracker_id => 1 |
|
1863 | get :new, :project_id => 1, :tracker_id => 1 | |
1956 | assert_response :success |
|
1864 | assert_response :success | |
1957 | assert_template 'new' |
|
|||
1958 |
|
1865 | |||
1959 | assert_select 'select[name=?][multiple=multiple]', "issue[custom_field_values][#{field.id}][]" do |
|
1866 | assert_select 'select[name=?][multiple=multiple]', "issue[custom_field_values][#{field.id}][]" do | |
1960 | assert_select 'option', Project.find(1).users.count |
|
1867 | assert_select 'option', Project.find(1).users.count | |
@@ -1988,7 +1895,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1988 | @request.session[:user_id] = 2 |
|
1895 | @request.session[:user_id] = 2 | |
1989 | get :new, :project_id => 1, :tracker_id => 1 |
|
1896 | get :new, :project_id => 1, :tracker_id => 1 | |
1990 | assert_response :success |
|
1897 | assert_response :success | |
1991 | assert_template 'new' |
|
|||
1992 | assert_select 'input[name=?]', 'issue[start_date]' |
|
1898 | assert_select 'input[name=?]', 'issue[start_date]' | |
1993 | assert_select 'input[name=?][value]', 'issue[start_date]', 0 |
|
1899 | assert_select 'input[name=?][value]', 'issue[start_date]', 0 | |
1994 | end |
|
1900 | end | |
@@ -1999,7 +1905,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
1999 | @request.session[:user_id] = 2 |
|
1905 | @request.session[:user_id] = 2 | |
2000 | get :new, :project_id => 1, :tracker_id => 1 |
|
1906 | get :new, :project_id => 1, :tracker_id => 1 | |
2001 | assert_response :success |
|
1907 | assert_response :success | |
2002 | assert_template 'new' |
|
|||
2003 | assert_select 'input[name=?][value=?]', 'issue[start_date]', |
|
1908 | assert_select 'input[name=?][value=?]', 'issue[start_date]', | |
2004 | Date.today.to_s |
|
1909 | Date.today.to_s | |
2005 | end |
|
1910 | end | |
@@ -2008,6 +1913,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
2008 | def test_get_new_form_should_allow_attachment_upload |
|
1913 | def test_get_new_form_should_allow_attachment_upload | |
2009 | @request.session[:user_id] = 2 |
|
1914 | @request.session[:user_id] = 2 | |
2010 | get :new, :project_id => 1, :tracker_id => 1 |
|
1915 | get :new, :project_id => 1, :tracker_id => 1 | |
|
1916 | assert_response :success | |||
2011 |
|
1917 | |||
2012 | assert_select 'form[id=issue-form][method=post][enctype="multipart/form-data"]' do |
|
1918 | assert_select 'form[id=issue-form][method=post][enctype="multipart/form-data"]' do | |
2013 | assert_select 'input[name=?][type=file]', 'attachments[dummy][file]' |
|
1919 | assert_select 'input[name=?][type=file]', 'attachments[dummy][file]' | |
@@ -2019,11 +1925,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2019 | get :new, :project_id => 1, |
|
1925 | get :new, :project_id => 1, | |
2020 | :issue => {:tracker_id => 3, :description => 'Prefilled', :custom_field_values => {'2' => 'Custom field value'}} |
|
1926 | :issue => {:tracker_id => 3, :description => 'Prefilled', :custom_field_values => {'2' => 'Custom field value'}} | |
2021 |
|
1927 | |||
2022 | issue = assigns(:issue) |
|
|||
2023 | assert_equal 3, issue.tracker_id |
|
|||
2024 | assert_equal 'Prefilled', issue.description |
|
|||
2025 | assert_equal 'Custom field value', issue.custom_field_value(2) |
|
|||
2026 |
|
||||
2027 | assert_select 'select[name=?]', 'issue[tracker_id]' do |
|
1928 | assert_select 'select[name=?]', 'issue[tracker_id]' do | |
2028 | assert_select 'option[value="3"][selected=selected]' |
|
1929 | assert_select 'option[value="3"][selected=selected]' | |
2029 | end |
|
1930 | end | |
@@ -2041,7 +1942,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2041 |
|
1942 | |||
2042 | get :new, :project_id => 1 |
|
1943 | get :new, :project_id => 1 | |
2043 | assert_response :success |
|
1944 | assert_response :success | |
2044 | assert_template 'new' |
|
|||
2045 |
|
1945 | |||
2046 | assert_select 'label[for=issue_start_date]' do |
|
1946 | assert_select 'label[for=issue_start_date]' do | |
2047 | assert_select 'span[class=required]', 0 |
|
1947 | assert_select 'span[class=required]', 0 | |
@@ -2067,7 +1967,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2067 |
|
1967 | |||
2068 | get :new, :project_id => 1 |
|
1968 | get :new, :project_id => 1 | |
2069 | assert_response :success |
|
1969 | assert_response :success | |
2070 | assert_template 'new' |
|
|||
2071 |
|
1970 | |||
2072 | assert_select 'input[name=?]', 'issue[start_date]' |
|
1971 | assert_select 'input[name=?]', 'issue[start_date]' | |
2073 | assert_select 'input[name=?]', 'issue[due_date]', 0 |
|
1972 | assert_select 'input[name=?]', 'issue[due_date]', 0 | |
@@ -2084,18 +1983,19 class IssuesControllerTest < Redmine::ControllerTest | |||||
2084 |
|
1983 | |||
2085 | get :new, :project_id => 1, :issue => {:status_id => 2} |
|
1984 | get :new, :project_id => 1, :issue => {:status_id => 2} | |
2086 | assert_select 'select[name=?]', 'issue[tracker_id]', 0 |
|
1985 | assert_select 'select[name=?]', 'issue[tracker_id]', 0 | |
2087 | assert_equal 2, assigns(:issue).status_id |
|
1986 | assert_select 'select[name=?]', 'issue[status_id]' do | |
|
1987 | assert_select 'option[value=?][selected=selected]', '2' | |||
|
1988 | end | |||
2088 | end |
|
1989 | end | |
2089 |
|
1990 | |||
2090 | def test_get_new_without_tracker_id |
|
1991 | def test_get_new_without_tracker_id | |
2091 | @request.session[:user_id] = 2 |
|
1992 | @request.session[:user_id] = 2 | |
2092 | get :new, :project_id => 1 |
|
1993 | get :new, :project_id => 1 | |
2093 | assert_response :success |
|
1994 | assert_response :success | |
2094 | assert_template 'new' |
|
|||
2095 |
|
1995 | |||
2096 | issue = assigns(:issue) |
|
1996 | assert_select 'select[name=?]', 'issue[tracker_id]' do | |
2097 | assert_not_nil issue |
|
1997 | assert_select 'option[value=?][selected=selected]', Project.find(1).trackers.first.id.to_s | |
2098 | assert_equal Project.find(1).trackers.first, issue.tracker |
|
1998 | end | |
2099 | end |
|
1999 | end | |
2100 |
|
2000 | |||
2101 | def test_get_new_with_no_default_status_should_display_an_error |
|
2001 | def test_get_new_with_no_default_status_should_display_an_error | |
@@ -2147,15 +2047,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
2147 | :description => 'This is the description', |
|
2047 | :description => 'This is the description', | |
2148 | :priority_id => 5} |
|
2048 | :priority_id => 5} | |
2149 | assert_response :success |
|
2049 | assert_response :success | |
2150 | assert_template 'new' |
|
|||
2151 | assert_template :partial => '_form' |
|
|||
2152 | assert_equal 'text/javascript', response.content_type |
|
2050 | assert_equal 'text/javascript', response.content_type | |
2153 |
|
2051 | assert_include 'This is the test_new issue', response.body | ||
2154 | issue = assigns(:issue) |
|
|||
2155 | assert_kind_of Issue, issue |
|
|||
2156 | assert_equal 1, issue.project_id |
|
|||
2157 | assert_equal 2, issue.tracker_id |
|
|||
2158 | assert_equal 'This is the test_new issue', issue.subject |
|
|||
2159 | end |
|
2052 | end | |
2160 |
|
2053 | |||
2161 | def test_update_form_for_new_issue_should_propose_transitions_based_on_initial_status |
|
2054 | def test_update_form_for_new_issue_should_propose_transitions_based_on_initial_status | |
@@ -2165,13 +2058,16 class IssuesControllerTest < Redmine::ControllerTest | |||||
2165 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 5) |
|
2058 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 5) | |
2166 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4) |
|
2059 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4) | |
2167 |
|
2060 | |||
2168 |
|
|
2061 | post :new, :project_id => 1, | |
2169 |
|
|
2062 | :issue => {:tracker_id => 1, | |
2170 |
|
|
2063 | :status_id => 5, | |
2171 |
|
|
2064 | :subject => 'This is an issue'} | |
2172 |
|
2065 | |||
2173 | assert_equal 5, assigns(:issue).status_id |
|
2066 | assert_select 'select[name=?]', 'issue[status_id]' do | |
2174 | assert_equal [2,5], assigns(:allowed_statuses).map(&:id).sort |
|
2067 | assert_select 'option[value=?][selected=selected]', '5' | |
|
2068 | assert_select 'option[value=?]', '2' | |||
|
2069 | assert_select 'option', :count => 2 | |||
|
2070 | end | |||
2175 | end |
|
2071 | end | |
2176 |
|
2072 | |||
2177 | def test_update_form_with_default_status_should_ignore_submitted_status_id_if_equals |
|
2073 | def test_update_form_with_default_status_should_ignore_submitted_status_id_if_equals | |
@@ -2180,12 +2076,15 class IssuesControllerTest < Redmine::ControllerTest | |||||
2180 | tracker.update! :default_status_id => 2 |
|
2076 | tracker.update! :default_status_id => 2 | |
2181 | tracker.generate_transitions! 2, 1, :clear => true |
|
2077 | tracker.generate_transitions! 2, 1, :clear => true | |
2182 |
|
2078 | |||
2183 |
|
|
2079 | post :new, :project_id => 1, | |
2184 |
|
|
2080 | :issue => {:tracker_id => 2, | |
2185 |
|
|
2081 | :status_id => 1}, | |
2186 |
|
|
2082 | :was_default_status => 1 | |
|
2083 | assert_response :success | |||
2187 |
|
2084 | |||
2188 | assert_equal 2, assigns(:issue).status_id |
|
2085 | assert_select 'select[name=?]', 'issue[status_id]' do | |
|
2086 | assert_select 'option[value=?][selected=selected]', '2' | |||
|
2087 | end | |||
2189 | end |
|
2088 | end | |
2190 |
|
2089 | |||
2191 | def test_update_form_for_new_issue_should_ignore_version_when_changing_project |
|
2090 | def test_update_form_for_new_issue_should_ignore_version_when_changing_project | |
@@ -2193,15 +2092,17 class IssuesControllerTest < Redmine::ControllerTest | |||||
2193 | Project.find(1).update_attribute :default_version_id, version.id |
|
2092 | Project.find(1).update_attribute :default_version_id, version.id | |
2194 | @request.session[:user_id] = 2 |
|
2093 | @request.session[:user_id] = 2 | |
2195 |
|
2094 | |||
2196 |
|
|
2095 | post :new, :issue => {:project_id => 1, | |
2197 |
|
|
2096 | :fixed_version_id => ''}, | |
2198 |
|
|
2097 | :form_update_triggered_by => 'issue_project_id' | |
2199 | assert_response :success |
|
2098 | assert_response :success | |
2200 | assert_template 'new' |
|
|||
2201 |
|
2099 | |||
2202 | issue = assigns(:issue) |
|
2100 | assert_select 'select[name=?]', 'issue[project_id]' do | |
2203 | assert_equal 1, issue.project_id |
|
2101 | assert_select 'option[value=?][selected=selected]', '1' | |
2204 | assert_equal version, issue.fixed_version |
|
2102 | end | |
|
2103 | assert_select 'select[name=?]', 'issue[fixed_version_id]' do | |||
|
2104 | assert_select 'option[value=?][selected=selected]', version.id.to_s | |||
|
2105 | end | |||
2205 | end |
|
2106 | end | |
2206 |
|
2107 | |||
2207 | def test_post_create |
|
2108 | def test_post_create | |
@@ -2391,9 +2292,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2391 | :priority_id => 5} |
|
2292 | :priority_id => 5} | |
2392 | end |
|
2293 | end | |
2393 | assert_response :success |
|
2294 | assert_response :success | |
2394 | assert_template 'new' |
|
|||
2395 | issue = assigns(:issue) |
|
|||
2396 | assert_not_nil issue |
|
|||
2397 | assert_select_error /Database cannot be blank/ |
|
2295 | assert_select_error /Database cannot be blank/ | |
2398 | end |
|
2296 | end | |
2399 |
|
2297 | |||
@@ -2415,7 +2313,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2415 | :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ''} |
|
2313 | :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ''} | |
2416 | } |
|
2314 | } | |
2417 | assert_response :success |
|
2315 | assert_response :success | |
2418 | assert_template 'new' |
|
|||
2419 | end |
|
2316 | end | |
2420 |
|
2317 | |||
2421 | assert_select_error /Due date cannot be blank/i |
|
2318 | assert_select_error /Due date cannot be blank/i | |
@@ -2440,7 +2337,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2440 | :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ['']} |
|
2337 | :custom_field_values => {cf1.id.to_s => '', cf2.id.to_s => ['']} | |
2441 | } |
|
2338 | } | |
2442 | assert_response :success |
|
2339 | assert_response :success | |
2443 | assert_template 'new' |
|
|||
2444 | end |
|
2340 | end | |
2445 |
|
2341 | |||
2446 | assert_select_error /Foo cannot be blank/i |
|
2342 | assert_select_error /Foo cannot be blank/i | |
@@ -2648,7 +2544,7 class IssuesControllerTest < Redmine::ControllerTest | |||||
2648 | end |
|
2544 | end | |
2649 | end |
|
2545 | end | |
2650 |
|
2546 | |||
2651 | def test_create_without_project_id_with_failure |
|
2547 | def test_create_without_project_id_with_failure_should_not_set_project | |
2652 | @request.session[:user_id] = 2 |
|
2548 | @request.session[:user_id] = 2 | |
2653 |
|
2549 | |||
2654 | post :create, |
|
2550 | post :create, | |
@@ -2656,7 +2552,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
2656 | :tracker_id => 2, |
|
2552 | :tracker_id => 2, | |
2657 | :subject => ''} |
|
2553 | :subject => ''} | |
2658 | assert_response :success |
|
2554 | assert_response :success | |
2659 | assert_nil assigns(:project) |
|
2555 | # no project menu | |
|
2556 | assert_select '#main-menu', 0 | |||
2660 | end |
|
2557 | end | |
2661 |
|
2558 | |||
2662 | def test_post_create_should_send_a_notification |
|
2559 | def test_post_create_should_send_a_notification | |
@@ -2688,7 +2585,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2688 | :priority_id => 6, |
|
2585 | :priority_id => 6, | |
2689 | :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}} |
|
2586 | :custom_field_values => {'1' => 'Oracle', '2' => 'Value for field 2'}} | |
2690 | assert_response :success |
|
2587 | assert_response :success | |
2691 | assert_template 'new' |
|
|||
2692 |
|
2588 | |||
2693 | assert_select 'textarea[name=?]', 'issue[description]', :text => 'This is a description' |
|
2589 | assert_select 'textarea[name=?]', 'issue[description]', :text => 'This is a description' | |
2694 | assert_select 'select[name=?]', 'issue[priority_id]' do |
|
2590 | assert_select 'select[name=?]', 'issue[priority_id]' do | |
@@ -2709,7 +2605,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2709 | :issue => {:tracker_id => 1, |
|
2605 | :issue => {:tracker_id => 1, | |
2710 | :watcher_user_ids => ['3', '8']} |
|
2606 | :watcher_user_ids => ['3', '8']} | |
2711 | assert_response :success |
|
2607 | assert_response :success | |
2712 | assert_template 'new' |
|
|||
2713 |
|
2608 | |||
2714 | assert_select 'input[name=?][value="2"]:not(checked)', 'issue[watcher_user_ids][]' |
|
2609 | assert_select 'input[name=?][value="2"]:not(checked)', 'issue[watcher_user_ids][]' | |
2715 | assert_select 'input[name=?][value="3"][checked=checked]', 'issue[watcher_user_ids][]' |
|
2610 | assert_select 'input[name=?][value="3"][checked=checked]', 'issue[watcher_user_ids][]' | |
@@ -2779,7 +2674,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2779 | :issue => { :tracker_id => '1', :subject => '' }, |
|
2674 | :issue => { :tracker_id => '1', :subject => '' }, | |
2780 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} |
|
2675 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} | |
2781 | assert_response :success |
|
2676 | assert_response :success | |
2782 | assert_template 'new' |
|
|||
2783 | end |
|
2677 | end | |
2784 | end |
|
2678 | end | |
2785 |
|
2679 | |||
@@ -2803,7 +2697,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
2803 | :issue => { :tracker_id => '1', :subject => '' }, |
|
2697 | :issue => { :tracker_id => '1', :subject => '' }, | |
2804 | :attachments => {'p0' => {'token' => attachment.token}} |
|
2698 | :attachments => {'p0' => {'token' => attachment.token}} | |
2805 | assert_response :success |
|
2699 | assert_response :success | |
2806 | assert_template 'new' |
|
|||
2807 | end |
|
2700 | end | |
2808 | end |
|
2701 | end | |
2809 |
|
2702 | |||
@@ -2842,14 +2735,10 class IssuesControllerTest < Redmine::ControllerTest | |||||
2842 | setup_without_workflow_privilege |
|
2735 | setup_without_workflow_privilege | |
2843 | get :new, :project_id => 1 |
|
2736 | get :new, :project_id => 1 | |
2844 | assert_response :success |
|
2737 | assert_response :success | |
2845 | assert_template 'new' |
|
|||
2846 |
|
||||
2847 | issue = assigns(:issue) |
|
|||
2848 | assert_not_nil issue.default_status |
|
|||
2849 |
|
2738 | |||
2850 | assert_select 'select[name=?]', 'issue[status_id]' do |
|
2739 | assert_select 'select[name=?]', 'issue[status_id]' do | |
2851 | assert_select 'option', 1 |
|
2740 | assert_select 'option', 1 | |
2852 |
assert_select 'option[value=?]', |
|
2741 | assert_select 'option[value=?][selected=selected]', '1' | |
2853 | end |
|
2742 | end | |
2854 | end |
|
2743 | end | |
2855 |
|
2744 | |||
@@ -2944,23 +2833,18 class IssuesControllerTest < Redmine::ControllerTest | |||||
2944 | end |
|
2833 | end | |
2945 |
|
2834 | |||
2946 | def test_new_as_copy |
|
2835 | def test_new_as_copy | |
|
2836 | orig = Issue.find(1) | |||
2947 | @request.session[:user_id] = 2 |
|
2837 | @request.session[:user_id] = 2 | |
2948 | get :new, :project_id => 1, :copy_from => 1 |
|
|||
2949 |
|
2838 | |||
|
2839 | get :new, :project_id => 1, :copy_from => orig.id | |||
2950 | assert_response :success |
|
2840 | assert_response :success | |
2951 | assert_template 'new' |
|
|||
2952 |
|
||||
2953 | assert_not_nil assigns(:issue) |
|
|||
2954 | orig = Issue.find(1) |
|
|||
2955 | assert_equal 1, assigns(:issue).project_id |
|
|||
2956 | assert_equal orig.subject, assigns(:issue).subject |
|
|||
2957 | assert assigns(:issue).copy? |
|
|||
2958 |
|
2841 | |||
2959 | assert_select 'form[id=issue-form][action="/projects/ecookbook/issues"]' do |
|
2842 | assert_select 'form[id=issue-form][action="/projects/ecookbook/issues"]' do | |
2960 | assert_select 'select[name=?]', 'issue[project_id]' do |
|
2843 | assert_select 'select[name=?]', 'issue[project_id]' do | |
2961 | assert_select 'option[value="1"][selected=selected]', :text => 'eCookbook' |
|
2844 | assert_select 'option[value="1"][selected=selected]', :text => 'eCookbook' | |
2962 | assert_select 'option[value="2"]:not([selected])', :text => 'OnlineStore' |
|
2845 | assert_select 'option[value="2"]:not([selected])', :text => 'OnlineStore' | |
2963 | end |
|
2846 | end | |
|
2847 | assert_select 'input[name=?][value=?]', 'issue[subject]', orig.subject | |||
2964 | assert_select 'input[name=copy_from][value="1"]' |
|
2848 | assert_select 'input[name=copy_from][value="1"]' | |
2965 | end |
|
2849 | end | |
2966 | end |
|
2850 | end | |
@@ -2970,9 +2854,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
2970 |
|
2854 | |||
2971 | @request.session[:user_id] = user.id |
|
2855 | @request.session[:user_id] = user.id | |
2972 | get :new, :project_id => 1, :copy_from => 1 |
|
2856 | get :new, :project_id => 1, :copy_from => 1 | |
2973 |
|
||||
2974 | assert_response :success |
|
2857 | assert_response :success | |
2975 | assert_template 'new' |
|
2858 | ||
2976 | assert_select 'select[name=?]', 'issue[project_id]' do |
|
2859 | assert_select 'select[name=?]', 'issue[project_id]' do | |
2977 | assert_select 'option[value="1"]', 0 |
|
2860 | assert_select 'option[value="1"]', 0 | |
2978 | assert_select 'option[value="2"]', :text => 'OnlineStore' |
|
2861 | assert_select 'option[value="2"]', :text => 'OnlineStore' | |
@@ -3024,9 +2907,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3024 | assert_difference 'Issue.count' do |
|
2907 | assert_difference 'Issue.count' do | |
3025 | post :create, :project_id => 1, :copy_from => 1, |
|
2908 | post :create, :project_id => 1, :copy_from => 1, | |
3026 | :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => 'Copy'} |
|
2909 | :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => 'Copy'} | |
3027 |
|
||||
3028 | assert_not_nil assigns(:issue) |
|
|||
3029 | assert assigns(:issue).copy? |
|
|||
3030 | end |
|
2910 | end | |
3031 | issue = Issue.order('id DESC').first |
|
2911 | issue = Issue.order('id DESC').first | |
3032 | assert_redirected_to "/issues/#{issue.id}" |
|
2912 | assert_redirected_to "/issues/#{issue.id}" | |
@@ -3202,10 +3082,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3202 | :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => ''} |
|
3082 | :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => ''} | |
3203 |
|
3083 | |||
3204 | assert_response :success |
|
3084 | assert_response :success | |
3205 | assert_template 'new' |
|
|||
3206 |
|
||||
3207 | assert_not_nil assigns(:issue) |
|
|||
3208 | assert assigns(:issue).copy? |
|
|||
3209 |
|
3085 | |||
3210 | assert_select 'form#issue-form[action="/projects/ecookbook/issues"]' do |
|
3086 | assert_select 'form#issue-form[action="/projects/ecookbook/issues"]' do | |
3211 | assert_select 'select[name=?]', 'issue[project_id]' do |
|
3087 | assert_select 'select[name=?]', 'issue[project_id]' do | |
@@ -3232,9 +3108,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3232 | @request.session[:user_id] = 2 |
|
3108 | @request.session[:user_id] = 2 | |
3233 | get :edit, :id => 1 |
|
3109 | get :edit, :id => 1 | |
3234 | assert_response :success |
|
3110 | assert_response :success | |
3235 | assert_template 'edit' |
|
|||
3236 | assert_not_nil assigns(:issue) |
|
|||
3237 | assert_equal Issue.find(1), assigns(:issue) |
|
|||
3238 |
|
3111 | |||
3239 | # Be sure we don't display inactive IssuePriorities |
|
3112 | # Be sure we don't display inactive IssuePriorities | |
3240 | assert ! IssuePriority.find(15).active? |
|
3113 | assert ! IssuePriority.find(15).active? | |
@@ -3264,17 +3137,11 class IssuesControllerTest < Redmine::ControllerTest | |||||
3264 | get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }, |
|
3137 | get :edit, :id => 1, :issue => { :status_id => 5, :priority_id => 7 }, | |
3265 | :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => 10 } |
|
3138 | :time_entry => { :hours => '2.5', :comments => 'test_get_edit_with_params', :activity_id => 10 } | |
3266 | assert_response :success |
|
3139 | assert_response :success | |
3267 | assert_template 'edit' |
|
|||
3268 |
|
3140 | |||
3269 | issue = assigns(:issue) |
|
|||
3270 | assert_not_nil issue |
|
|||
3271 |
|
||||
3272 | assert_equal 5, issue.status_id |
|
|||
3273 | assert_select 'select[name=?]', 'issue[status_id]' do |
|
3141 | assert_select 'select[name=?]', 'issue[status_id]' do | |
3274 | assert_select 'option[value="5"][selected=selected]', :text => 'Closed' |
|
3142 | assert_select 'option[value="5"][selected=selected]', :text => 'Closed' | |
3275 | end |
|
3143 | end | |
3276 |
|
3144 | |||
3277 | assert_equal 7, issue.priority_id |
|
|||
3278 | assert_select 'select[name=?]', 'issue[priority_id]' do |
|
3145 | assert_select 'select[name=?]', 'issue[priority_id]' do | |
3279 | assert_select 'option[value="7"][selected=selected]', :text => 'Urgent' |
|
3146 | assert_select 'option[value="7"][selected=selected]', :text => 'Urgent' | |
3280 | end |
|
3147 | end | |
@@ -3296,7 +3163,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3296 | @request.session[:user_id] = 2 |
|
3163 | @request.session[:user_id] = 2 | |
3297 | get :edit, :id => 1 |
|
3164 | get :edit, :id => 1 | |
3298 | assert_response :success |
|
3165 | assert_response :success | |
3299 | assert_template 'edit' |
|
|||
3300 |
|
3166 | |||
3301 | assert_select 'select[name=?][multiple=multiple]', 'issue[custom_field_values][1][]' do |
|
3167 | assert_select 'select[name=?][multiple=multiple]', 'issue[custom_field_values][1][]' do | |
3302 | assert_select 'option', 3 |
|
3168 | assert_select 'option', 3 | |
@@ -3315,27 +3181,16 class IssuesControllerTest < Redmine::ControllerTest | |||||
3315 | :priority_id => 5} |
|
3181 | :priority_id => 5} | |
3316 | assert_response :success |
|
3182 | assert_response :success | |
3317 | assert_equal 'text/javascript', response.content_type |
|
3183 | assert_equal 'text/javascript', response.content_type | |
3318 | assert_template 'edit' |
|
|||
3319 | assert_template :partial => '_form' |
|
|||
3320 |
|
3184 | |||
3321 | issue = assigns(:issue) |
|
3185 | assert_include 'This is the test_new issue', response.body | |
3322 | assert_kind_of Issue, issue |
|
|||
3323 | assert_equal 1, issue.id |
|
|||
3324 | assert_equal 1, issue.project_id |
|
|||
3325 | assert_equal 2, issue.tracker_id |
|
|||
3326 | assert_equal 'This is the test_new issue', issue.subject |
|
|||
3327 | end |
|
3186 | end | |
3328 |
|
3187 | |||
3329 | def test_update_form_for_existing_issue_should_keep_issue_author |
|
3188 | def test_update_form_for_existing_issue_should_keep_issue_author | |
3330 | @request.session[:user_id] = 3 |
|
3189 | @request.session[:user_id] = 3 | |
3331 |
|
|
3190 | patch :edit, :id => 1, :issue => {:subject => 'Changed'} | |
3332 | assert_response :success |
|
3191 | assert_response :success | |
3333 | assert_equal 'text/javascript', response.content_type |
|
|||
3334 |
|
3192 | |||
3335 | issue = assigns(:issue) |
|
3193 | assert_equal User.find(2), Issue.find(1).author | |
3336 | assert_equal User.find(2), issue.author |
|
|||
3337 | assert_equal 2, issue.author_id |
|
|||
3338 | assert_not_equal User.current, issue.author |
|
|||
3339 | end |
|
3194 | end | |
3340 |
|
3195 | |||
3341 | def test_update_form_for_existing_issue_should_propose_transitions_based_on_initial_status |
|
3196 | def test_update_form_for_existing_issue_should_propose_transitions_based_on_initial_status | |
@@ -3345,32 +3200,35 class IssuesControllerTest < Redmine::ControllerTest | |||||
3345 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5) |
|
3200 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5) | |
3346 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4) |
|
3201 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4) | |
3347 |
|
3202 | |||
3348 |
|
|
3203 | patch :edit, :id => 2, | |
3349 |
|
|
3204 | :issue => {:tracker_id => 2, | |
3350 |
|
|
3205 | :status_id => 5, | |
3351 |
|
|
3206 | :subject => 'This is an issue'} | |
3352 |
|
3207 | |||
3353 | assert_equal 5, assigns(:issue).status_id |
|
3208 | assert_select 'select[name=?]', 'issue[status_id]' do | |
3354 | assert_equal [1,2,5], assigns(:allowed_statuses).map(&:id).sort |
|
3209 | assert_select 'option[value="1"]' | |
|
3210 | assert_select 'option[value="2"]' | |||
|
3211 | assert_select 'option[value="5"][selected=selected]' | |||
|
3212 | assert_select 'option', 3 | |||
|
3213 | end | |||
3355 | end |
|
3214 | end | |
3356 |
|
3215 | |||
3357 | def test_update_form_for_existing_issue_with_project_change |
|
3216 | def test_update_form_for_existing_issue_with_project_change | |
3358 | @request.session[:user_id] = 2 |
|
3217 | @request.session[:user_id] = 2 | |
3359 |
|
|
3218 | patch :edit, :id => 1, | |
3360 |
|
|
3219 | :issue => {:project_id => 2, | |
3361 |
|
|
3220 | :tracker_id => 2, | |
3362 |
|
|
3221 | :subject => 'This is the test_new issue', | |
3363 |
|
|
3222 | :description => 'This is the description', | |
3364 |
|
|
3223 | :priority_id => 5} | |
3365 | assert_response :success |
|
3224 | assert_response :success | |
3366 | assert_template :partial => '_form' |
|
3225 | assert_select 'select[name=?]', 'issue[project_id]' do | |
3367 |
|
3226 | assert_select 'option[value="2"][selected=selected]' | ||
3368 | issue = assigns(:issue) |
|
3227 | end | |
3369 | assert_kind_of Issue, issue |
|
3228 | assert_select 'select[name=?]', 'issue[tracker_id]' do | |
3370 | assert_equal 1, issue.id |
|
3229 | assert_select 'option[value="2"][selected=selected]' | |
3371 | assert_equal 2, issue.project_id |
|
3230 | end | |
3372 | assert_equal 2, issue.tracker_id |
|
3231 | assert_select 'input[name=?][value=?]', 'issue[subject]', 'This is the test_new issue' | |
3373 | assert_equal 'This is the test_new issue', issue.subject |
|
|||
3374 | end |
|
3232 | end | |
3375 |
|
3233 | |||
3376 | def test_update_form_should_keep_category_with_same_when_changing_project |
|
3234 | def test_update_form_should_keep_category_with_same_when_changing_project | |
@@ -3382,11 +3240,12 class IssuesControllerTest < Redmine::ControllerTest | |||||
3382 |
|
3240 | |||
3383 | @request.session[:user_id] = 1 |
|
3241 | @request.session[:user_id] = 1 | |
3384 | patch :edit, :id => issue.id, |
|
3242 | patch :edit, :id => issue.id, | |
3385 | :issue => {:project_id => target.id, :category_id => source_category.id} |
|
3243 | :issue => {:project_id => target.id, :category_id => source_category.id} | |
3386 | assert_response :success |
|
3244 | assert_response :success | |
3387 |
|
3245 | |||
3388 | issue = assigns(:issue) |
|
3246 | assert_select 'select[name=?]', 'issue[category_id]' do | |
3389 | assert_equal target_category, issue.category |
|
3247 | assert_select 'option[value=?][selected=selected]', target_category.id.to_s | |
|
3248 | end | |||
3390 | end |
|
3249 | end | |
3391 |
|
3250 | |||
3392 | def test_update_form_should_propose_default_status_for_existing_issue |
|
3251 | def test_update_form_should_propose_default_status_for_existing_issue | |
@@ -3394,9 +3253,13 class IssuesControllerTest < Redmine::ControllerTest | |||||
3394 | WorkflowTransition.delete_all |
|
3253 | WorkflowTransition.delete_all | |
3395 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3) |
|
3254 | WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3) | |
3396 |
|
3255 | |||
3397 |
|
|
3256 | patch :edit, :id => 2 | |
3398 | assert_response :success |
|
3257 | assert_response :success | |
3399 | assert_equal [2,3], assigns(:allowed_statuses).map(&:id).sort |
|
3258 | assert_select 'select[name=?]', 'issue[status_id]' do | |
|
3259 | assert_select 'option[value="2"]' | |||
|
3260 | assert_select 'option[value="3"]' | |||
|
3261 | assert_select 'option', 2 | |||
|
3262 | end | |||
3400 | end |
|
3263 | end | |
3401 |
|
3264 | |||
3402 | def test_put_update_without_custom_fields_param |
|
3265 | def test_put_update_without_custom_fields_param | |
@@ -3691,7 +3554,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3691 | :issue => { :subject => '' }, |
|
3554 | :issue => { :subject => '' }, | |
3692 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} |
|
3555 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'test file'}} | |
3693 | assert_response :success |
|
3556 | assert_response :success | |
3694 | assert_template 'edit' |
|
|||
3695 | end |
|
3557 | end | |
3696 | end |
|
3558 | end | |
3697 |
|
3559 | |||
@@ -3715,7 +3577,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3715 | :issue => { :subject => '' }, |
|
3577 | :issue => { :subject => '' }, | |
3716 | :attachments => {'p0' => {'token' => attachment.token}} |
|
3578 | :attachments => {'p0' => {'token' => attachment.token}} | |
3717 | assert_response :success |
|
3579 | assert_response :success | |
3718 | assert_template 'edit' |
|
|||
3719 | end |
|
3580 | end | |
3720 | end |
|
3581 | end | |
3721 |
|
3582 | |||
@@ -3842,7 +3703,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3842 | :time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"} |
|
3703 | :time_entry => {"comments"=>"", "activity_id"=>"", "hours"=>"2z"} | |
3843 | end |
|
3704 | end | |
3844 | assert_response :success |
|
3705 | assert_response :success | |
3845 | assert_template 'edit' |
|
|||
3846 |
|
3706 | |||
3847 | assert_select_error /Activity cannot be blank/ |
|
3707 | assert_select_error /Activity cannot be blank/ | |
3848 | assert_select 'textarea[name=?]', 'issue[notes]', :text => notes |
|
3708 | assert_select 'textarea[name=?]', 'issue[notes]', :text => notes | |
@@ -3860,7 +3720,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3860 | :time_entry => {"comments"=>"this is my comment", "activity_id"=>"", "hours"=>""} |
|
3720 | :time_entry => {"comments"=>"this is my comment", "activity_id"=>"", "hours"=>""} | |
3861 | end |
|
3721 | end | |
3862 | assert_response :success |
|
3722 | assert_response :success | |
3863 | assert_template 'edit' |
|
|||
3864 |
|
3723 | |||
3865 | assert_select_error /Activity cannot be blank/ |
|
3724 | assert_select_error /Activity cannot be blank/ | |
3866 | assert_select_error /Hours cannot be blank/ |
|
3725 | assert_select_error /Hours cannot be blank/ | |
@@ -3955,7 +3814,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3955 | @request.session[:user_id] = 2 |
|
3814 | @request.session[:user_id] = 2 | |
3956 | get :bulk_edit, :ids => [1, 3] |
|
3815 | get :bulk_edit, :ids => [1, 3] | |
3957 | assert_response :success |
|
3816 | assert_response :success | |
3958 | assert_template 'bulk_edit' |
|
|||
3959 |
|
3817 | |||
3960 | assert_select 'ul#bulk-selection' do |
|
3818 | assert_select 'ul#bulk-selection' do | |
3961 | assert_select 'li', 2 |
|
3819 | assert_select 'li', 2 | |
@@ -3991,7 +3849,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
3991 | @request.session[:user_id] = 2 |
|
3849 | @request.session[:user_id] = 2 | |
3992 | get :bulk_edit, :ids => [1, 2, 6] |
|
3850 | get :bulk_edit, :ids => [1, 2, 6] | |
3993 | assert_response :success |
|
3851 | assert_response :success | |
3994 | assert_template 'bulk_edit' |
|
|||
3995 |
|
3852 | |||
3996 | # Can not set issues from different projects as children of an issue |
|
3853 | # Can not set issues from different projects as children of an issue | |
3997 | assert_select 'input[name=?]', 'issue[parent_issue_id]', 0 |
|
3854 | assert_select 'input[name=?]', 'issue[parent_issue_id]', 0 | |
@@ -4009,7 +3866,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
4009 | @request.session[:user_id] = 2 |
|
3866 | @request.session[:user_id] = 2 | |
4010 | get :bulk_edit, :ids => [1, 2] |
|
3867 | get :bulk_edit, :ids => [1, 2] | |
4011 | assert_response :success |
|
3868 | assert_response :success | |
4012 | assert_template 'bulk_edit' |
|
|||
4013 |
|
3869 | |||
4014 | assert_select 'select.user_cf[name=?]', "issue[custom_field_values][#{field.id}]" do |
|
3870 | assert_select 'select.user_cf[name=?]', "issue[custom_field_values][#{field.id}]" do | |
4015 | assert_select 'option', Project.find(1).users.count + 2 # "no change" + "none" options |
|
3871 | assert_select 'option', Project.find(1).users.count + 2 # "no change" + "none" options | |
@@ -4022,7 +3878,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
4022 | @request.session[:user_id] = 2 |
|
3878 | @request.session[:user_id] = 2 | |
4023 | get :bulk_edit, :ids => [1, 2] |
|
3879 | get :bulk_edit, :ids => [1, 2] | |
4024 | assert_response :success |
|
3880 | assert_response :success | |
4025 | assert_template 'bulk_edit' |
|
|||
4026 |
|
3881 | |||
4027 | assert_select 'select.version_cf[name=?]', "issue[custom_field_values][#{field.id}]" do |
|
3882 | assert_select 'select.version_cf[name=?]', "issue[custom_field_values][#{field.id}]" do | |
4028 | assert_select 'option', Project.find(1).shared_versions.count + 2 # "no change" + "none" options |
|
3883 | assert_select 'option', Project.find(1).shared_versions.count + 2 # "no change" + "none" options | |
@@ -4036,7 +3891,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
4036 | @request.session[:user_id] = 2 |
|
3891 | @request.session[:user_id] = 2 | |
4037 | get :bulk_edit, :ids => [1, 3] |
|
3892 | get :bulk_edit, :ids => [1, 3] | |
4038 | assert_response :success |
|
3893 | assert_response :success | |
4039 | assert_template 'bulk_edit' |
|
|||
4040 |
|
3894 | |||
4041 | assert_select 'select[name=?]', 'issue[custom_field_values][1][]' do |
|
3895 | assert_select 'select[name=?]', 'issue[custom_field_values][1][]' do | |
4042 | assert_select 'option', field.possible_values.size + 1 # "none" options |
|
3896 | assert_select 'option', field.possible_values.size + 1 # "none" options | |
@@ -4046,6 +3900,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
4046 | def test_bulk_edit_should_propose_to_clear_text_custom_fields |
|
3900 | def test_bulk_edit_should_propose_to_clear_text_custom_fields | |
4047 | @request.session[:user_id] = 2 |
|
3901 | @request.session[:user_id] = 2 | |
4048 | get :bulk_edit, :ids => [1, 3] |
|
3902 | get :bulk_edit, :ids => [1, 3] | |
|
3903 | assert_response :success | |||
|
3904 | ||||
4049 | assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', '__none__' |
|
3905 | assert_select 'input[name=?][value=?]', 'issue[custom_field_values][2]', '__none__' | |
4050 | end |
|
3906 | end | |
4051 |
|
3907 | |||
@@ -4066,12 +3922,10 class IssuesControllerTest < Redmine::ControllerTest | |||||
4066 | @request.session[:user_id] = 2 |
|
3922 | @request.session[:user_id] = 2 | |
4067 | get :bulk_edit, :ids => [1, 2] |
|
3923 | get :bulk_edit, :ids => [1, 2] | |
4068 |
|
3924 | |||
4069 | assert_response :success |
|
|||
4070 | statuses = assigns(:available_statuses) |
|
|||
4071 | assert_not_nil statuses |
|
|||
4072 | assert_equal [1, 3], statuses.map(&:id).sort |
|
|||
4073 |
|
||||
4074 | assert_select 'select[name=?]', 'issue[status_id]' do |
|
3925 | assert_select 'select[name=?]', 'issue[status_id]' do | |
|
3926 | assert_select 'option[value=""]' | |||
|
3927 | assert_select 'option[value="1"]' | |||
|
3928 | assert_select 'option[value="3"]' | |||
4075 | assert_select 'option', 3 # 2 statuses + "no change" option |
|
3929 | assert_select 'option', 3 # 2 statuses + "no change" option | |
4076 | end |
|
3930 | end | |
4077 | end |
|
3931 | end | |
@@ -4080,11 +3934,16 class IssuesControllerTest < Redmine::ControllerTest | |||||
4080 | @request.session[:user_id] = 2 |
|
3934 | @request.session[:user_id] = 2 | |
4081 | post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1} |
|
3935 | post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1} | |
4082 | assert_response :success |
|
3936 | assert_response :success | |
4083 | assert_template 'bulk_edit' |
|
3937 | ||
4084 |
|
|
3938 | expected_versions = Project.find(1).shared_versions.open.to_a.sort | |
4085 |
|
3939 | |||
4086 | assert_select 'select[name=?]', 'issue[fixed_version_id]' do |
|
3940 | assert_select 'select[name=?]', 'issue[fixed_version_id]' do | |
4087 | assert_select 'option', :text => '2.0' |
|
3941 | expected_versions.each do |version| | |
|
3942 | assert_select 'option[value=?]', version.id.to_s | |||
|
3943 | end | |||
|
3944 | assert_select 'option[value=""]' | |||
|
3945 | assert_select 'option[value="none"]' | |||
|
3946 | assert_select 'option', expected_versions.size + 2 | |||
4088 | end |
|
3947 | end | |
4089 | end |
|
3948 | end | |
4090 |
|
3949 | |||
@@ -4092,23 +3951,31 class IssuesControllerTest < Redmine::ControllerTest | |||||
4092 | @request.session[:user_id] = 2 |
|
3951 | @request.session[:user_id] = 2 | |
4093 | post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1} |
|
3952 | post :bulk_edit, :ids => [1, 2, 6], :issue => {:project_id => 1} | |
4094 | assert_response :success |
|
3953 | assert_response :success | |
4095 | assert_template 'bulk_edit' |
|
3954 | ||
4096 |
|
|
3955 | expected_categories = Project.find(1).issue_categories.sort | |
4097 |
|
3956 | |||
4098 | assert_select 'select[name=?]', 'issue[category_id]' do |
|
3957 | assert_select 'select[name=?]', 'issue[category_id]' do | |
4099 | assert_select 'option', :text => 'Recipes' |
|
3958 | expected_categories.each do |category| | |
|
3959 | assert_select 'option[value=?]', category.id.to_s | |||
|
3960 | end | |||
|
3961 | assert_select 'option[value=""]' | |||
|
3962 | assert_select 'option[value="none"]' | |||
|
3963 | assert_select 'option', expected_categories.size + 2 | |||
4100 | end |
|
3964 | end | |
4101 | end |
|
3965 | end | |
4102 |
|
3966 | |||
4103 | def test_bulk_edit_should_only_propose_issues_trackers_custom_fields |
|
3967 | def test_bulk_edit_should_only_propose_issues_trackers_custom_fields | |
4104 | IssueCustomField.delete_all |
|
3968 | IssueCustomField.delete_all | |
4105 | field = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true) |
|
3969 | field1 = IssueCustomField.generate!(:tracker_ids => [1], :is_for_all => true) | |
4106 | IssueCustomField.generate!(:tracker_ids => [2], :is_for_all => true) |
|
3970 | field2 = IssueCustomField.generate!(:tracker_ids => [2], :is_for_all => true) | |
4107 | @request.session[:user_id] = 2 |
|
3971 | @request.session[:user_id] = 2 | |
4108 |
|
3972 | |||
4109 | issue_ids = Issue.where(:project_id => 1, :tracker_id => 1).limit(2).ids |
|
3973 | issue_ids = Issue.where(:project_id => 1, :tracker_id => 1).limit(2).ids | |
4110 | get :bulk_edit, :ids => issue_ids |
|
3974 | get :bulk_edit, :ids => issue_ids | |
4111 | assert_equal [field], assigns(:custom_fields) |
|
3975 | assert_response :success | |
|
3976 | ||||
|
3977 | assert_select 'input[name=?]', "issue[custom_field_values][#{field1.id}]" | |||
|
3978 | assert_select 'input[name=?]', "issue[custom_field_values][#{field2.id}]", 0 | |||
4112 | end |
|
3979 | end | |
4113 |
|
3980 | |||
4114 | def test_bulk_update |
|
3981 | def test_bulk_update | |
@@ -4389,13 +4256,10 class IssuesControllerTest < Redmine::ControllerTest | |||||
4389 | def test_bulk_update_with_all_failures_should_show_errors |
|
4256 | def test_bulk_update_with_all_failures_should_show_errors | |
4390 | @request.session[:user_id] = 2 |
|
4257 | @request.session[:user_id] = 2 | |
4391 | post :bulk_update, :ids => [1, 2], :issue => {:start_date => 'foo'} |
|
4258 | post :bulk_update, :ids => [1, 2], :issue => {:start_date => 'foo'} | |
4392 |
|
||||
4393 | assert_response :success |
|
4259 | assert_response :success | |
4394 | assert_template 'bulk_edit' |
|
4260 | ||
4395 | assert_select '#errorExplanation span', :text => 'Failed to save 2 issue(s) on 2 selected: #1, #2.' |
|
4261 | assert_select '#errorExplanation span', :text => 'Failed to save 2 issue(s) on 2 selected: #1, #2.' | |
4396 | assert_select '#errorExplanation ul li', :text => 'Start date is not a valid date: #1, #2' |
|
4262 | assert_select '#errorExplanation ul li', :text => 'Start date is not a valid date: #1, #2' | |
4397 |
|
||||
4398 | assert_equal [1, 2], assigns[:issues].map(&:id) |
|
|||
4399 | end |
|
4263 | end | |
4400 |
|
4264 | |||
4401 | def test_bulk_update_with_some_failures_should_show_errors |
|
4265 | def test_bulk_update_with_some_failures_should_show_errors | |
@@ -4406,20 +4270,20 class IssuesControllerTest < Redmine::ControllerTest | |||||
4406 | post :bulk_update, :ids => [issue1.id, issue2.id, issue3.id], |
|
4270 | post :bulk_update, :ids => [issue1.id, issue2.id, issue3.id], | |
4407 | :issue => {:due_date => '2013-05-01'} |
|
4271 | :issue => {:due_date => '2013-05-01'} | |
4408 | assert_response :success |
|
4272 | assert_response :success | |
4409 | assert_template 'bulk_edit' |
|
4273 | ||
4410 | assert_select '#errorExplanation span', |
|
4274 | assert_select '#errorExplanation span', | |
4411 | :text => "Failed to save 2 issue(s) on 3 selected: ##{issue1.id}, ##{issue2.id}." |
|
4275 | :text => "Failed to save 2 issue(s) on 3 selected: ##{issue1.id}, ##{issue2.id}." | |
4412 | assert_select '#errorExplanation ul li', |
|
4276 | assert_select '#errorExplanation ul li', | |
4413 | :text => "Due date must be greater than start date: ##{issue1.id}, ##{issue2.id}" |
|
4277 | :text => "Due date must be greater than start date: ##{issue1.id}, ##{issue2.id}" | |
4414 | assert_equal [issue1.id, issue2.id], assigns[:issues].map(&:id) |
|
4278 | ||
|
4279 | assert_select '#bulk-selection li', 2 | |||
4415 | end |
|
4280 | end | |
4416 |
|
4281 | |||
4417 | def test_bulk_update_with_failure_should_preserved_form_values |
|
4282 | def test_bulk_update_with_failure_should_preserved_form_values | |
4418 | @request.session[:user_id] = 2 |
|
4283 | @request.session[:user_id] = 2 | |
4419 | post :bulk_update, :ids => [1, 2], :issue => {:tracker_id => '2', :start_date => 'foo'} |
|
4284 | post :bulk_update, :ids => [1, 2], :issue => {:tracker_id => '2', :start_date => 'foo'} | |
4420 |
|
||||
4421 | assert_response :success |
|
4285 | assert_response :success | |
4422 | assert_template 'bulk_edit' |
|
4286 | ||
4423 | assert_select 'select[name=?]', 'issue[tracker_id]' do |
|
4287 | assert_select 'select[name=?]', 'issue[tracker_id]' do | |
4424 | assert_select 'option[value="2"][selected=selected]' |
|
4288 | assert_select 'option[value="2"][selected=selected]' | |
4425 | end |
|
4289 | end | |
@@ -4430,11 +4294,8 class IssuesControllerTest < Redmine::ControllerTest | |||||
4430 | @request.session[:user_id] = 2 |
|
4294 | @request.session[:user_id] = 2 | |
4431 | get :bulk_edit, :ids => [1, 2, 3], :copy => '1' |
|
4295 | get :bulk_edit, :ids => [1, 2, 3], :copy => '1' | |
4432 | assert_response :success |
|
4296 | assert_response :success | |
4433 | assert_template 'bulk_edit' |
|
|||
4434 |
|
4297 | |||
4435 | issues = assigns(:issues) |
|
4298 | assert_select '#bulk-selection li', 3 | |
4436 | assert_not_nil issues |
|
|||
4437 | assert_equal [1, 2, 3], issues.map(&:id).sort |
|
|||
4438 |
|
4299 | |||
4439 | assert_select 'select[name=?]', 'issue[project_id]' do |
|
4300 | assert_select 'select[name=?]', 'issue[project_id]' do | |
4440 | assert_select 'option[value=""]' |
|
4301 | assert_select 'option[value=""]' | |
@@ -4448,7 +4309,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
4448 |
|
4309 | |||
4449 | get :bulk_edit, :ids => [1, 2, 3], :copy => '1' |
|
4310 | get :bulk_edit, :ids => [1, 2, 3], :copy => '1' | |
4450 | assert_response :success |
|
4311 | assert_response :success | |
4451 | assert_template 'bulk_edit' |
|
|||
4452 |
|
4312 | |||
4453 | assert_select 'select[name=?]', 'issue[project_id]' do |
|
4313 | assert_select 'select[name=?]', 'issue[project_id]' do | |
4454 | assert_select 'option[value=""]', 0 |
|
4314 | assert_select 'option[value=""]', 0 | |
@@ -4688,9 +4548,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
4688 | delete :destroy, :ids => [1, 3] |
|
4548 | delete :destroy, :ids => [1, 3] | |
4689 | end |
|
4549 | end | |
4690 | assert_response :success |
|
4550 | assert_response :success | |
4691 | assert_template 'destroy' |
|
|||
4692 | assert_not_nil assigns(:hours) |
|
|||
4693 | assert Issue.find_by_id(1) && Issue.find_by_id(3) |
|
|||
4694 |
|
4551 | |||
4695 | assert_select 'form' do |
|
4552 | assert_select 'form' do | |
4696 | assert_select 'input[name=_method][value=delete]' |
|
4553 | assert_select 'input[name=_method][value=delete]' | |
@@ -4748,7 +4605,6 class IssuesControllerTest < Redmine::ControllerTest | |||||
4748 | end |
|
4605 | end | |
4749 | end |
|
4606 | end | |
4750 | assert_response :success |
|
4607 | assert_response :success | |
4751 | assert_template 'destroy' |
|
|||
4752 | end |
|
4608 | end | |
4753 |
|
4609 | |||
4754 | def test_destroy_issues_from_different_projects |
|
4610 | def test_destroy_issues_from_different_projects |
@@ -68,7 +68,6 class IssuesControllerTransactionTest < Redmine::ControllerTest | |||||
68 | end |
|
68 | end | |
69 |
|
69 | |||
70 | assert_response :success |
|
70 | assert_response :success | |
71 | assert_template 'edit' |
|
|||
72 |
|
71 | |||
73 | assert_select 'div.conflict' |
|
72 | assert_select 'div.conflict' | |
74 | assert_select 'input[name=?][value=?]', 'conflict_resolution', 'overwrite' |
|
73 | assert_select 'input[name=?][value=?]', 'conflict_resolution', 'overwrite' | |
@@ -101,7 +100,7 class IssuesControllerTransactionTest < Redmine::ControllerTest | |||||
101 | end |
|
100 | end | |
102 |
|
101 | |||
103 | assert_response :success |
|
102 | assert_response :success | |
104 | assert_template 'edit' |
|
103 | ||
105 | attachment = Attachment.order('id DESC').first |
|
104 | attachment = Attachment.order('id DESC').first | |
106 | assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token |
|
105 | assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token | |
107 | assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt' |
|
106 | assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt' | |
@@ -117,6 +116,7 class IssuesControllerTransactionTest < Redmine::ControllerTest | |||||
117 | :notes => '', |
|
116 | :notes => '', | |
118 | :lock_version => (issue.lock_version - 1) |
|
117 | :lock_version => (issue.lock_version - 1) | |
119 | } |
|
118 | } | |
|
119 | assert_response :success | |||
120 |
|
120 | |||
121 | assert_select 'div.conflict' |
|
121 | assert_select 'div.conflict' | |
122 | assert_select 'input[name=conflict_resolution][value=overwrite]' |
|
122 | assert_select 'input[name=conflict_resolution][value=overwrite]' | |
@@ -134,11 +134,9 class IssuesControllerTransactionTest < Redmine::ControllerTest | |||||
134 | :lock_version => 2 |
|
134 | :lock_version => 2 | |
135 | }, |
|
135 | }, | |
136 | :last_journal_id => 1 |
|
136 | :last_journal_id => 1 | |
|
137 | assert_response :success | |||
137 |
|
138 | |||
138 |
assert_ |
|
139 | assert_select '.conflict-journal', 1 | |
139 | assert_equal 1, assigns(:conflict_journals).size |
|
|||
140 | assert_equal 2, assigns(:conflict_journals).first.id |
|
|||
141 |
|
||||
142 | assert_select 'div.conflict', :text => /Some notes with Redmine links/ |
|
140 | assert_select 'div.conflict', :text => /Some notes with Redmine links/ | |
143 | end |
|
141 | end | |
144 |
|
142 | |||
@@ -152,9 +150,9 class IssuesControllerTransactionTest < Redmine::ControllerTest | |||||
152 | :lock_version => 2 |
|
150 | :lock_version => 2 | |
153 | }, |
|
151 | }, | |
154 | :last_journal_id => '' |
|
152 | :last_journal_id => '' | |
|
153 | assert_response :success | |||
155 |
|
154 | |||
156 |
assert_ |
|
155 | assert_select '.conflict-journal', 2 | |
157 | assert_equal 2, assigns(:conflict_journals).size |
|
|||
158 | assert_select 'div.conflict', :text => /Some notes with Redmine links/ |
|
156 | assert_select 'div.conflict', :text => /Some notes with Redmine links/ | |
159 | assert_select 'div.conflict', :text => /Journal notes/ |
|
157 | assert_select 'div.conflict', :text => /Journal notes/ | |
160 | end |
|
158 | end | |
@@ -164,11 +162,13 class IssuesControllerTransactionTest < Redmine::ControllerTest | |||||
164 |
|
162 | |||
165 | @request.session[:user_id] = 2 |
|
163 | @request.session[:user_id] = 2 | |
166 | put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => '' |
|
164 | put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => '' | |
167 | assert_include journal, assigns(:conflict_journals) |
|
165 | assert_response :success | |
|
166 | assert_select '.conflict-journal', :text => /Privates notes/ | |||
168 |
|
167 | |||
169 | Role.find(1).remove_permission! :view_private_notes |
|
168 | Role.find(1).remove_permission! :view_private_notes | |
170 | put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => '' |
|
169 | put :update, :id => 1, :issue => {:fixed_version_id => 4, :lock_version => 2}, :last_journal_id => '' | |
171 | assert_not_include journal, assigns(:conflict_journals) |
|
170 | assert_response :success | |
|
171 | assert_select '.conflict-journal', :text => /Privates notes/, :count => 0 | |||
172 | end |
|
172 | end | |
173 |
|
173 | |||
174 | def test_update_stale_issue_with_overwrite_conflict_resolution_should_update |
|
174 | def test_update_stale_issue_with_overwrite_conflict_resolution_should_update |
@@ -213,14 +213,14 class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest | |||||
213 |
|
213 | |||
214 | get :index, :sort => "cf_#{@field2.id}" |
|
214 | get :index, :sort => "cf_#{@field2.id}" | |
215 | # ValueB is not visible to user and ignored while sorting |
|
215 | # ValueB is not visible to user and ignored while sorting | |
216 |
assert_equal %w(ValueB ValueA ValueC), |
|
216 | assert_equal %w(ValueB ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)} | |
217 |
|
217 | |||
218 | get :index, :set_filter => '1', "cf_#{@field2.id}" => '*' |
|
218 | get :index, :set_filter => '1', "cf_#{@field2.id}" => '*' | |
219 |
assert_equal %w(ValueA ValueC), |
|
219 | assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)} | |
220 |
|
220 | |||
221 | CustomField.update_all(:field_format => 'list') |
|
221 | CustomField.update_all(:field_format => 'list') | |
222 | get :index, :group => "cf_#{@field2.id}" |
|
222 | get :index, :group => "cf_#{@field2.id}" | |
223 |
assert_equal %w(ValueA ValueC), |
|
223 | assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)} | |
224 | end |
|
224 | end | |
225 |
|
225 | |||
226 | def test_create_should_send_notifications_according_custom_fields_visibility |
|
226 | def test_create_should_send_notifications_according_custom_fields_visibility |
@@ -28,7 +28,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
28 | def test_index |
|
28 | def test_index | |
29 | get :index, :project_id => 1 |
|
29 | get :index, :project_id => 1 | |
30 | assert_response :success |
|
30 | assert_response :success | |
31 | assert_not_nil assigns(:journals) |
|
|||
32 | assert_equal 'application/atom+xml', @response.content_type |
|
31 | assert_equal 'application/atom+xml', @response.content_type | |
33 | end |
|
32 | end | |
34 |
|
33 | |||
@@ -43,12 +42,12 class JournalsControllerTest < Redmine::ControllerTest | |||||
43 |
|
42 | |||
44 | get :index, :project_id => 1 |
|
43 | get :index, :project_id => 1 | |
45 | assert_response :success |
|
44 | assert_response :success | |
46 | assert_include journal, assigns(:journals) |
|
45 | assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}" | |
47 |
|
46 | |||
48 | Role.find(1).remove_permission! :view_private_notes |
|
47 | Role.find(1).remove_permission! :view_private_notes | |
49 | get :index, :project_id => 1 |
|
48 | get :index, :project_id => 1 | |
50 | assert_response :success |
|
49 | assert_response :success | |
51 | assert_not_include journal, assigns(:journals) |
|
50 | assert_select 'entry>id', :text => "http://test.host/issues/2?journal_id=#{journal.id}", :count => 0 | |
52 | end |
|
51 | end | |
53 |
|
52 | |||
54 | def test_index_should_show_visible_custom_fields_only |
|
53 | def test_index_should_show_visible_custom_fields_only | |
@@ -94,7 +93,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
94 | def test_diff_for_description_change |
|
93 | def test_diff_for_description_change | |
95 | get :diff, :id => 3, :detail_id => 4 |
|
94 | get :diff, :id => 3, :detail_id => 4 | |
96 | assert_response :success |
|
95 | assert_response :success | |
97 | assert_template 'diff' |
|
|||
98 |
|
96 | |||
99 | assert_select 'span.diff_out', :text => /removed/ |
|
97 | assert_select 'span.diff_out', :text => /removed/ | |
100 | assert_select 'span.diff_in', :text => /added/ |
|
98 | assert_select 'span.diff_in', :text => /added/ | |
@@ -108,7 +106,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
108 |
|
106 | |||
109 | get :diff, :id => journal.id, :detail_id => detail.id |
|
107 | get :diff, :id => journal.id, :detail_id => detail.id | |
110 | assert_response :success |
|
108 | assert_response :success | |
111 | assert_template 'diff' |
|
|||
112 |
|
109 | |||
113 | assert_select 'span.diff_out', :text => /Foo/ |
|
110 | assert_select 'span.diff_out', :text => /Foo/ | |
114 | assert_select 'span.diff_in', :text => /Bar/ |
|
111 | assert_select 'span.diff_in', :text => /Bar/ | |
@@ -127,7 +124,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
127 | def test_diff_should_default_to_description_diff |
|
124 | def test_diff_should_default_to_description_diff | |
128 | get :diff, :id => 3 |
|
125 | get :diff, :id => 3 | |
129 | assert_response :success |
|
126 | assert_response :success | |
130 | assert_template 'diff' |
|
|||
131 |
|
127 | |||
132 | assert_select 'span.diff_out', :text => /removed/ |
|
128 | assert_select 'span.diff_out', :text => /removed/ | |
133 | assert_select 'span.diff_in', :text => /added/ |
|
129 | assert_select 'span.diff_in', :text => /added/ | |
@@ -137,7 +133,7 class JournalsControllerTest < Redmine::ControllerTest | |||||
137 | @request.session[:user_id] = 2 |
|
133 | @request.session[:user_id] = 2 | |
138 | xhr :get, :new, :id => 6 |
|
134 | xhr :get, :new, :id => 6 | |
139 | assert_response :success |
|
135 | assert_response :success | |
140 | assert_template 'new' |
|
136 | ||
141 | assert_equal 'text/javascript', response.content_type |
|
137 | assert_equal 'text/javascript', response.content_type | |
142 | assert_include '> This is an issue', response.body |
|
138 | assert_include '> This is an issue', response.body | |
143 | end |
|
139 | end | |
@@ -152,7 +148,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
152 | @request.session[:user_id] = 2 |
|
148 | @request.session[:user_id] = 2 | |
153 | xhr :get, :new, :id => 6, :journal_id => 4 |
|
149 | xhr :get, :new, :id => 6, :journal_id => 4 | |
154 | assert_response :success |
|
150 | assert_response :success | |
155 | assert_template 'new' |
|
|||
156 | assert_equal 'text/javascript', response.content_type |
|
151 | assert_equal 'text/javascript', response.content_type | |
157 | assert_include '> A comment with a private version', response.body |
|
152 | assert_include '> A comment with a private version', response.body | |
158 | end |
|
153 | end | |
@@ -163,7 +158,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
163 |
|
158 | |||
164 | xhr :get, :new, :id => 2, :journal_id => journal.id |
|
159 | xhr :get, :new, :id => 2, :journal_id => journal.id | |
165 | assert_response :success |
|
160 | assert_response :success | |
166 | assert_template 'new' |
|
|||
167 | assert_equal 'text/javascript', response.content_type |
|
161 | assert_equal 'text/javascript', response.content_type | |
168 | assert_include '> Privates notes', response.body |
|
162 | assert_include '> Privates notes', response.body | |
169 |
|
163 | |||
@@ -176,7 +170,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
176 | @request.session[:user_id] = 1 |
|
170 | @request.session[:user_id] = 1 | |
177 | xhr :get, :edit, :id => 2 |
|
171 | xhr :get, :edit, :id => 2 | |
178 | assert_response :success |
|
172 | assert_response :success | |
179 | assert_template 'edit' |
|
|||
180 | assert_equal 'text/javascript', response.content_type |
|
173 | assert_equal 'text/javascript', response.content_type | |
181 | assert_include 'textarea', response.body |
|
174 | assert_include 'textarea', response.body | |
182 | end |
|
175 | end | |
@@ -188,7 +181,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
188 |
|
181 | |||
189 | xhr :get, :edit, :id => journal.id |
|
182 | xhr :get, :edit, :id => journal.id | |
190 | assert_response :success |
|
183 | assert_response :success | |
191 | assert_template 'edit' |
|
|||
192 | assert_equal 'text/javascript', response.content_type |
|
184 | assert_equal 'text/javascript', response.content_type | |
193 | assert_include 'textarea', response.body |
|
185 | assert_include 'textarea', response.body | |
194 |
|
186 | |||
@@ -201,7 +193,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
201 | @request.session[:user_id] = 1 |
|
193 | @request.session[:user_id] = 1 | |
202 | xhr :post, :update, :id => 2, :journal => {:notes => 'Updated notes'} |
|
194 | xhr :post, :update, :id => 2, :journal => {:notes => 'Updated notes'} | |
203 | assert_response :success |
|
195 | assert_response :success | |
204 | assert_template 'update' |
|
|||
205 | assert_equal 'text/javascript', response.content_type |
|
196 | assert_equal 'text/javascript', response.content_type | |
206 | assert_equal 'Updated notes', Journal.find(2).notes |
|
197 | assert_equal 'Updated notes', Journal.find(2).notes | |
207 | assert_include 'journal-2-notes', response.body |
|
198 | assert_include 'journal-2-notes', response.body | |
@@ -211,7 +202,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
211 | @request.session[:user_id] = 1 |
|
202 | @request.session[:user_id] = 1 | |
212 | xhr :post, :update, :id => 2, :journal => {:private_notes => '1'} |
|
203 | xhr :post, :update, :id => 2, :journal => {:private_notes => '1'} | |
213 | assert_response :success |
|
204 | assert_response :success | |
214 | assert_template 'update' |
|
|||
215 | assert_equal 'text/javascript', response.content_type |
|
205 | assert_equal 'text/javascript', response.content_type | |
216 | assert_equal true, Journal.find(2).private_notes |
|
206 | assert_equal true, Journal.find(2).private_notes | |
217 | assert_include 'change-2', response.body |
|
207 | assert_include 'change-2', response.body | |
@@ -223,7 +213,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
223 | @request.session[:user_id] = 1 |
|
213 | @request.session[:user_id] = 1 | |
224 | xhr :post, :update, :id => 2, :journal => {:private_notes => '0'} |
|
214 | xhr :post, :update, :id => 2, :journal => {:private_notes => '0'} | |
225 | assert_response :success |
|
215 | assert_response :success | |
226 | assert_template 'update' |
|
|||
227 | assert_equal 'text/javascript', response.content_type |
|
216 | assert_equal 'text/javascript', response.content_type | |
228 | assert_equal false, Journal.find(2).private_notes |
|
217 | assert_equal false, Journal.find(2).private_notes | |
229 | assert_include 'change-2', response.body |
|
218 | assert_include 'change-2', response.body | |
@@ -246,7 +235,6 class JournalsControllerTest < Redmine::ControllerTest | |||||
246 | assert_difference 'Journal.count', -1 do |
|
235 | assert_difference 'Journal.count', -1 do | |
247 | xhr :post, :update, :id => 2, :journal => {:notes => ''} |
|
236 | xhr :post, :update, :id => 2, :journal => {:notes => ''} | |
248 | assert_response :success |
|
237 | assert_response :success | |
249 | assert_template 'update' |
|
|||
250 | assert_equal 'text/javascript', response.content_type |
|
238 | assert_equal 'text/javascript', response.content_type | |
251 | end |
|
239 | end | |
252 | assert_nil Journal.find_by_id(2) |
|
240 | assert_nil Journal.find_by_id(2) |
@@ -93,7 +93,6 class MembersControllerTest < Redmine::ControllerTest | |||||
93 | assert_difference 'Member.count', 3 do |
|
93 | assert_difference 'Member.count', 3 do | |
94 | xhr :post, :create, :project_id => 1, :membership => {:role_ids => [1], :user_ids => [7, 8, 9]} |
|
94 | xhr :post, :create, :project_id => 1, :membership => {:role_ids => [1], :user_ids => [7, 8, 9]} | |
95 | assert_response :success |
|
95 | assert_response :success | |
96 | assert_template 'create' |
|
|||
97 | assert_equal 'text/javascript', response.content_type |
|
96 | assert_equal 'text/javascript', response.content_type | |
98 | end |
|
97 | end | |
99 | assert User.find(7).member_of?(Project.find(1)) |
|
98 | assert User.find(7).member_of?(Project.find(1)) | |
@@ -106,7 +105,6 class MembersControllerTest < Redmine::ControllerTest | |||||
106 | assert_no_difference 'Member.count' do |
|
105 | assert_no_difference 'Member.count' do | |
107 | xhr :post, :create, :project_id => 1, :membership => {:role_ids => [], :user_ids => [7, 8, 9]} |
|
106 | xhr :post, :create, :project_id => 1, :membership => {:role_ids => [], :user_ids => [7, 8, 9]} | |
108 | assert_response :success |
|
107 | assert_response :success | |
109 | assert_template 'create' |
|
|||
110 | assert_equal 'text/javascript', response.content_type |
|
108 | assert_equal 'text/javascript', response.content_type | |
111 | end |
|
109 | end | |
112 | assert_match /alert/, response.body, "Alert message not sent" |
|
110 | assert_match /alert/, response.body, "Alert message not sent" | |
@@ -143,7 +141,6 class MembersControllerTest < Redmine::ControllerTest | |||||
143 | assert_no_difference 'Member.count' do |
|
141 | assert_no_difference 'Member.count' do | |
144 | xhr :put, :update, :id => 2, :membership => {:role_ids => [1], :user_id => 3} |
|
142 | xhr :put, :update, :id => 2, :membership => {:role_ids => [1], :user_id => 3} | |
145 | assert_response :success |
|
143 | assert_response :success | |
146 | assert_template 'update' |
|
|||
147 | assert_equal 'text/javascript', response.content_type |
|
144 | assert_equal 'text/javascript', response.content_type | |
148 | end |
|
145 | end | |
149 | member = Member.find(2) |
|
146 | member = Member.find(2) | |
@@ -186,7 +183,6 class MembersControllerTest < Redmine::ControllerTest | |||||
186 | assert_difference 'Member.count', -1 do |
|
183 | assert_difference 'Member.count', -1 do | |
187 | xhr :delete, :destroy, :id => 2 |
|
184 | xhr :delete, :destroy, :id => 2 | |
188 | assert_response :success |
|
185 | assert_response :success | |
189 | assert_template 'destroy' |
|
|||
190 | assert_equal 'text/javascript', response.content_type |
|
186 | assert_equal 'text/javascript', response.content_type | |
191 | end |
|
187 | end | |
192 | assert_nil Member.find_by_id(2) |
|
188 | assert_nil Member.find_by_id(2) |
@@ -282,6 +282,29 module Redmine | |||||
282 | end |
|
282 | end | |
283 |
|
283 | |||
284 | class ControllerTest < ActionController::TestCase |
|
284 | class ControllerTest < ActionController::TestCase | |
|
285 | # Returns the issues that are displayed in the list in the same order | |||
|
286 | def issues_in_list | |||
|
287 | ids = css_select('tr.issue td.id').map(&:text).map(&:to_i) | |||
|
288 | Issue.where(:id => ids).sort_by {|issue| ids.index(issue.id)} | |||
|
289 | end | |||
|
290 | ||||
|
291 | # Return the columns that are displayed in the list | |||
|
292 | def columns_in_issues_list | |||
|
293 | css_select('table.issues thead th:not(.checkbox)').map(&:text) | |||
|
294 | end | |||
|
295 | ||||
|
296 | # Verifies that the query filters match the expected filters | |||
|
297 | def assert_query_filters(expected_filters) | |||
|
298 | response.body =~ /initFilters\(\);\s*((addFilter\(.+\);\s*)*)/ | |||
|
299 | filter_init = $1.to_s | |||
|
300 | ||||
|
301 | expected_filters.each do |field, operator, values| | |||
|
302 | s = "addFilter(#{field.to_json}, #{operator.to_json}, #{Array(values).to_json});" | |||
|
303 | assert_include s, filter_init | |||
|
304 | end | |||
|
305 | assert_equal expected_filters.size, filter_init.scan("addFilter").size, "filters counts don't match" | |||
|
306 | end | |||
|
307 | ||||
285 | def process(method, path, parameters={}, session={}, flash={}) |
|
308 | def process(method, path, parameters={}, session={}, flash={}) | |
286 | if parameters.key?(:params) || parameters.key?(:session) |
|
309 | if parameters.key?(:params) || parameters.key?(:session) | |
287 | raise ArgumentError if session.present? |
|
310 | raise ArgumentError if session.present? |
General Comments 0
You need to be logged in to leave comments.
Login now