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 | ||
|---|---|---|
|
def available_totalable_columns_tags(query)
|
||
|
tags = ''.html_safe
|
||
|
query.available_totalable_columns.each do |column|
|
||
|
tags << content_tag('label', check_box_tag('t[]', column.name.to_s, query.totalable_columns.include?(column), :id => nil) + " #{column.caption}", :class => 'inline')
|
||
|
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\');')
|
||
|
end
|
||
|
tags
|
||
|
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 | ||
|---|---|---|
|
end
|
||
|
self.group_by = params[:group_by] || (params[:query] && params[:query][:group_by])
|
||
|
self.column_names = params[:c] || (params[:query] && params[:query][:column_names])
|
||
|
options[:include_totals] = params[:include_totals].present? ? params[:include_totals].match(/false/).nil? : true
|
||
|
self.totalable_names = params[:t] || (params[:query] && params[:query][:totalable_names])
|
||
|
self
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
def totalable_names
|
||
|
options[:totalable_names] || Setting.issue_list_default_totals.map(&:to_sym) || []
|
||
|
options[:include_totals] = true unless !options[:include_totals].nil?
|
||
|
options[:totalable_names] || options[:include_totals] && Setting.issue_list_default_totals.map(&:to_sym) || []
|
||
|
end
|
||
|
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 | ||
|---|---|---|
|
</tr>
|
||
|
<tr>
|
||
|
<td><%= l(:label_total_plural) %></td>
|
||
|
<td><%= available_totalable_columns_tags(@query) %></td>
|
||
|
<td><%= available_totalable_columns_tags(@query) %>
|
||
|
<%= hidden_field_tag('include_totals', params[:include_totals]) %></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</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 | ||
|---|---|---|
|
assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
|
||
|
assert Issue.find(4).watched_by?(User.find_by_login('jsmith'))
|
||
|
end
|
||
|
def test_issue_list_with_default_totalable_columns
|
||
|
log_user('admin', 'admin')
|
||
|
with_settings :issue_list_default_totals => ['estimated_hours'] do
|
||
|
visit '/projects/ecookbook/issues'
|
||
|
# Check that the page shows the Estimated hours total
|
||
|
assert page.has_css?('p.query-totals')
|
||
|
assert page.has_css?('span.total-for-estimated-hours')
|
||
|
# Open the Options of the form (necessary for having the totalable columns options clickable)
|
||
|
page.all('legend')[1].click
|
||
|
# Deselect the default totalable column (none should be left)
|
||
|
page.first('input[name="t[]"][value="estimated_hours"]').click
|
||
|
page.execute_script("$('form#query_form').submit()")
|
||
|
sleep (1)
|
||
|
# Check that Totals are not present in the reloaded page
|
||
|
assert !page.has_css?('p.query-totals')
|
||
|
assert !page.has_css?('span.total-for-estimated-hours')
|
||
|
end
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- 2
- Next »