Defect #22123 » Totalable_columns-with_test.patch
app/helpers/queries_helper.rb Sun Mar 13 17:17:27 2016 +0000 → app/helpers/queries_helper.rb Thu Apr 28 16:15:21 2016 +0200 | ||
---|---|---|
87 | 87 |
def available_totalable_columns_tags(query) |
88 | 88 |
tags = ''.html_safe |
89 | 89 |
query.available_totalable_columns.each do |column| |
90 |
tags << content_tag('label', check_box_tag('t[]', column.name.to_s, query.totalable_columns.include?(column), :id => nil) + " #{column.caption}", :class => 'inline') |
|
90 |
tags << content_tag('label', check_box_tag('t[]', column.name.to_s, query.totalable_columns.include?(column), :id => nil) + " #{column.caption}", :class => 'inline', :onchange => 'document.getElementById(\'include_totals\').value=$(\'input[name="t[]"]\').is(\':checked\');')
|
|
91 | 91 |
end |
92 | 92 |
tags |
93 | 93 |
end |
app/models/query.rb Sun Mar 13 17:17:27 2016 +0000 → app/models/query.rb Thu Apr 28 16:15:21 2016 +0200 | ||
---|---|---|
250 | 250 |
end |
251 | 251 |
self.group_by = params[:group_by] || (params[:query] && params[:query][:group_by]) |
252 | 252 |
self.column_names = params[:c] || (params[:query] && params[:query][:column_names]) |
253 |
options[:include_totals] = params[:include_totals].present? ? params[:include_totals].match(/false/).nil? : true |
|
253 | 254 |
self.totalable_names = params[:t] || (params[:query] && params[:query][:totalable_names]) |
254 | 255 |
self |
255 | 256 |
end |
... | ... | |
511 | 512 |
end |
512 | 513 | |
513 | 514 |
def totalable_names |
514 |
options[:totalable_names] || Setting.issue_list_default_totals.map(&:to_sym) || [] |
|
515 |
options[:include_totals] = true unless !options[:include_totals].nil? |
|
516 |
options[:totalable_names] || options[:include_totals] && Setting.issue_list_default_totals.map(&:to_sym) || [] |
|
515 | 517 |
end |
516 | 518 | |
517 | 519 |
def sort_criteria=(arg) |
app/views/issues/index.html.erb Sun Mar 13 17:17:27 2016 +0000 → app/views/issues/index.html.erb Thu Apr 28 16:15:21 2016 +0200 | ||
---|---|---|
41 | 41 |
</tr> |
42 | 42 |
<tr> |
43 | 43 |
<td><%= l(:label_total_plural) %></td> |
44 |
<td><%= available_totalable_columns_tags(@query) %></td> |
|
44 |
<td><%= available_totalable_columns_tags(@query) %> |
|
45 |
<%= hidden_field_tag('include_totals', params[:include_totals]) %></td> |
|
45 | 46 |
</tr> |
46 | 47 |
</table> |
47 | 48 |
</div> |
test/ui/issues_test_ui.rb Sun Mar 13 17:17:27 2016 +0000 → test/ui/issues_test_ui.rb Thu Apr 28 16:15:21 2016 +0200 | ||
---|---|---|
290 | 290 |
assert Issue.find(1).watched_by?(User.find_by_login('jsmith')) |
291 | 291 |
assert Issue.find(4).watched_by?(User.find_by_login('jsmith')) |
292 | 292 |
end |
293 | ||
294 |
def test_issue_list_with_default_totalable_columns |
|
295 |
log_user('admin', 'admin') |
|
296 |
with_settings :issue_list_default_totals => ['estimated_hours'] do |
|
297 |
visit '/projects/ecookbook/issues' |
|
298 |
# Check that the page shows the Estimated hours total |
|
299 |
assert page.has_css?('p.query-totals') |
|
300 |
assert page.has_css?('span.total-for-estimated-hours') |
|
301 |
# Open the Options of the form (necessary for having the totalable columns options clickable) |
|
302 |
page.all('legend')[1].click |
|
303 |
# Deselect the default totalable column (none should be left) |
|
304 |
page.first('input[name="t[]"][value="estimated_hours"]').click |
|
305 |
page.execute_script("$('form#query_form').submit()") |
|
306 |
sleep (1) |
|
307 |
# Check that Totals are not present in the reloaded page |
|
308 |
assert !page.has_css?('p.query-totals') |
|
309 |
assert !page.has_css?('span.total-for-estimated-hours') |
|
310 |
end |
|
311 |
end |
|
293 | 312 |
end |
- « Previous
- 1
- 2
- Next »