Feature #1474 » add_last_notes_column_v3.diff
| app/helpers/queries_helper.rb | ||
|---|---|---|
|
value ? (value.visible? ? link_to_issue(value, :subject => false) : "##{value.id}") : ''
|
||
|
when :description
|
||
|
item.description? ? content_tag('div', textilizable(item, :description), :class => "wiki") : ''
|
||
|
when :last_notes
|
||
|
item.last_notes.present? ? content_tag('div', textilizable(item, :last_notes), :class => "wiki") : ''
|
||
|
when :done_ratio
|
||
|
progress_bar(value)
|
||
|
when :relations
|
||
| app/models/issue.rb | ||
|---|---|---|
|
@spent_hours = nil
|
||
|
@total_spent_hours = nil
|
||
|
@total_estimated_hours = nil
|
||
|
@last_notes = nil
|
||
|
base_reload(*args)
|
||
|
end
|
||
| ... | ... | |
|
@relations ||= IssueRelation::Relations.new(self, (relations_from + relations_to).sort)
|
||
|
end
|
||
|
def last_notes
|
||
|
if @last_notes
|
||
|
@last_notes
|
||
|
else
|
||
|
notes = self.journals.where.not(notes: '').to_a
|
||
|
notes.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, self.project)
|
||
|
notes.last.notes unless notes.empty?
|
||
|
end
|
||
|
end
|
||
|
# Preloads relations for a collection of issues
|
||
|
def self.load_relations(issues)
|
||
|
if issues.any?
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
# Preloads visible last notes for a collection of issues
|
||
|
def self.load_visible_last_notes(issues, user=User.current)
|
||
|
if issues.any?
|
||
|
issue_ids = issues.map(&:id)
|
||
|
notes = Journal.joins(issue: :project).where.not(notes: '').
|
||
|
where(:issues => {:id => issue_ids}).order("#{Journal.table_name}.id ASC").to_a
|
||
|
issues.each do |issue|
|
||
|
note = notes.select{|note| note.journalized_id == issue.id}
|
||
|
note.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, issue.project)
|
||
|
issue.instance_variable_set "@last_notes", (note.empty? ? '' : note.last.notes)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
# Finds an issue relation given its id.
|
||
|
def find_relation(relation_id)
|
||
|
IssueRelation.where("issue_to_id = ? OR issue_from_id = ?", id, id).find(relation_id)
|
||
| app/models/issue_query.rb | ||
|---|---|---|
|
QueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc'),
|
||
|
QueryColumn.new(:closed_on, :sortable => "#{Issue.table_name}.closed_on", :default_order => 'desc'),
|
||
|
QueryColumn.new(:relations, :caption => :label_related_issues),
|
||
|
QueryColumn.new(:description, :inline => false)
|
||
|
QueryColumn.new(:description, :inline => false),
|
||
|
QueryColumn.new(:last_notes, :caption => :label_last_notes, :inline => false)
|
||
|
]
|
||
|
def initialize(attributes=nil, *args)
|
||
| ... | ... | |
|
if has_column?(:relations)
|
||
|
Issue.load_visible_relations(issues)
|
||
|
end
|
||
|
if has_column?(:last_notes)
|
||
|
Issue.load_visible_last_notes(issues)
|
||
|
end
|
||
|
issues
|
||
|
rescue ::ActiveRecord::StatementInvalid => e
|
||
|
raise StatementInvalid.new(e.message)
|
||
| app/views/issues/_list.html.erb | ||
|---|---|---|
|
<% @query.block_columns.each do |column|
|
||
|
if (text = column_content(column, issue)) && text.present? -%>
|
||
|
<tr class="<%= current_cycle %>">
|
||
|
<td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>"><%= text %></td>
|
||
|
<td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>">
|
||
|
<% if query.block_columns.count > 1 %>
|
||
|
<span><%= column.caption %></span>
|
||
|
<% end %>
|
||
|
<%= text %>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<% end -%>
|
||
|
<% end -%>
|
||
| app/views/issues/index.html.erb | ||
|---|---|---|
|
</p>
|
||
|
<p>
|
||
|
<label><%= check_box_tag 'csv[description]', '1', @query.has_column?(:description) %> <%= l(:field_description) %></label>
|
||
|
<label><%= check_box_tag 'csv[last_notes]', '1', @query.has_column?(:last_notes) %> <%= l(:label_last_notes) %></label>
|
||
|
</p>
|
||
|
<% if @issue_count > Setting.issues_export_limit.to_i %>
|
||
|
<p class="icon icon-warning">
|
||
| app/views/timelog/_list.html.erb | ||
|---|---|---|
|
<% @query.block_columns.each do |column|
|
||
|
if (text = column_content(column, issue)) && text.present? -%>
|
||
|
<tr class="<%= current_cycle %>">
|
||
|
<td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>"><%= text %></td>
|
||
|
<td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>">
|
||
|
<% if query.block_columns.count > 1 %>
|
||
|
<span><%= column.caption %></span>
|
||
|
<% end %>
|
||
|
<%= text %>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<% end -%>
|
||
|
<% end -%>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_font_default: Default font
|
||
|
label_font_monospace: Monospaced font
|
||
|
label_font_proportional: Proportional font
|
||
|
label_last_notes: Last notes
|
||
|
button_login: Login
|
||
|
button_submit: Submit
|
||
| lib/redmine/export/pdf/issues_pdf_helper.rb | ||
|---|---|---|
|
pdf.SetFontStyle('',8)
|
||
|
pdf.RDMMultiCell(190, 5, "#{format_time(issue.created_on)} - #{issue.author}")
|
||
|
pdf.ln
|
||
|
|
||
|
left = []
|
||
|
left << [l(:field_status), issue.status]
|
||
|
left << [l(:field_priority), issue.priority]
|
||
|
left << [l(:field_assigned_to), issue.assigned_to] unless issue.disabled_core_fields.include?('assigned_to_id')
|
||
|
left << [l(:field_category), issue.category] unless issue.disabled_core_fields.include?('category_id')
|
||
|
left << [l(:field_fixed_version), issue.fixed_version] unless issue.disabled_core_fields.include?('fixed_version_id')
|
||
|
|
||
|
right = []
|
||
|
right << [l(:field_start_date), format_date(issue.start_date)] unless issue.disabled_core_fields.include?('start_date')
|
||
|
right << [l(:field_due_date), format_date(issue.due_date)] unless issue.disabled_core_fields.include?('due_date')
|
||
|
right << [l(:field_done_ratio), "#{issue.done_ratio}%"] unless issue.disabled_core_fields.include?('done_ratio')
|
||
|
right << [l(:field_estimated_hours), l_hours(issue.estimated_hours)] unless issue.disabled_core_fields.include?('estimated_hours')
|
||
|
right << [l(:label_spent_time), l_hours(issue.total_spent_hours)] if User.current.allowed_to?(:view_time_entries, issue.project)
|
||
|
|
||
|
rows = left.size > right.size ? left.size : right.size
|
||
|
while left.size < rows
|
||
|
left << nil
|
||
| ... | ... | |
|
while right.size < rows
|
||
|
right << nil
|
||
|
end
|
||
|
|
||
|
half = (issue.visible_custom_field_values.size / 2.0).ceil
|
||
|
issue.visible_custom_field_values.each_with_index do |custom_value, i|
|
||
|
(i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)]
|
||
|
end
|
||
|
|
||
|
if pdf.get_rtl
|
||
|
border_first_top = 'RT'
|
||
|
border_last_top = 'LT'
|
||
| ... | ... | |
|
border_first = 'L'
|
||
|
border_last = 'R'
|
||
|
end
|
||
|
|
||
|
rows = left.size > right.size ? left.size : right.size
|
||
|
rows.times do |i|
|
||
|
heights = []
|
||
| ... | ... | |
|
item = right[i]
|
||
|
heights << pdf.get_string_height(60, item ? item.last.to_s : "")
|
||
|
height = heights.max
|
||
|
|
||
|
item = left[i]
|
||
|
pdf.SetFontStyle('B',9)
|
||
|
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0)
|
||
|
pdf.SetFontStyle('',9)
|
||
|
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 0)
|
||
|
|
||
|
item = right[i]
|
||
|
pdf.SetFontStyle('B',9)
|
||
|
pdf.RDMMultiCell(35, height, item ? "#{item.first}:" : "", (i == 0 ? border_first_top : border_first), '', 0, 0)
|
||
|
pdf.SetFontStyle('',9)
|
||
|
pdf.RDMMultiCell(60, height, item ? item.last.to_s : "", (i == 0 ? border_last_top : border_last), '', 0, 2)
|
||
|
|
||
|
pdf.set_x(base_x)
|
||
|
end
|
||
|
|
||
|
pdf.SetFontStyle('B',9)
|
||
|
pdf.RDMCell(35+155, 5, l(:field_description), "LRT", 1)
|
||
|
pdf.SetFontStyle('',9)
|
||
|
|
||
|
# Set resize image scale
|
||
|
pdf.set_image_scale(1.6)
|
||
|
text = textilizable(issue, :description,
|
||
| ... | ... | |
|
:inline_attachments => false
|
||
|
)
|
||
|
pdf.RDMwriteFormattedCell(35+155, 5, '', '', text, issue.attachments, "LRB")
|
||
|
|
||
|
unless issue.leaf?
|
||
|
truncate_length = (!is_cjk? ? 90 : 65)
|
||
|
pdf.SetFontStyle('B',9)
|
||
| ... | ... | |
|
pdf.ln
|
||
|
end
|
||
|
end
|
||
|
|
||
|
relations = issue.relations.select { |r| r.other_issue(issue).visible? }
|
||
|
unless relations.empty?
|
||
|
truncate_length = (!is_cjk? ? 80 : 60)
|
||
| ... | ... | |
|
end
|
||
|
pdf.RDMCell(190,5, "", "T")
|
||
|
pdf.ln
|
||
|
|
||
|
if issue.changesets.any? &&
|
||
|
User.current.allowed_to?(:view_changesets, issue.project)
|
||
|
pdf.SetFontStyle('B',9)
|
||
| ... | ... | |
|
pdf.ln
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if assoc[:journals].present?
|
||
|
pdf.SetFontStyle('B',9)
|
||
|
pdf.RDMCell(190,5, l(:label_history), "B")
|
||
| ... | ... | |
|
pdf.ln
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if issue.attachments.any?
|
||
|
pdf.SetFontStyle('B',9)
|
||
|
pdf.RDMCell(190,5, l(:label_attachment_plural), "B")
|
||
| ... | ... | |
|
pdf.footer_date = format_date(User.current.today)
|
||
|
pdf.set_auto_page_break(false)
|
||
|
pdf.add_page("L")
|
||
|
|
||
|
# Landscape A4 = 210 x 297 mm
|
||
|
page_height = pdf.get_page_height # 210
|
||
|
page_width = pdf.get_page_width # 297
|
||
| ... | ... | |
|
right_margin = pdf.get_original_margins['right'] # 10
|
||
|
bottom_margin = pdf.get_footer_margin
|
||
|
row_height = 4
|
||
|
|
||
|
# column widths
|
||
|
table_width = page_width - right_margin - left_margin
|
||
|
col_width = []
|
||
| ... | ... | |
|
col_width = calc_col_width(issues, query, table_width, pdf)
|
||
|
table_width = col_width.inject(0, :+)
|
||
|
end
|
||
|
|
||
|
# use full width if the description is displayed
|
||
|
if table_width > 0 && query.has_column?(:description)
|
||
|
# use full width if the description or last_notes are displayed
|
||
|
if table_width > 0 && (query.has_column?(:description) || query.has_column?(:last_notes))
|
||
|
col_width = col_width.map {|w| w * (page_width - right_margin - left_margin) / table_width}
|
||
|
table_width = col_width.inject(0, :+)
|
||
|
end
|
||
|
|
||
|
# title
|
||
|
pdf.SetFontStyle('B',11)
|
||
|
pdf.RDMCell(190, 8, title)
|
||
| ... | ... | |
|
end
|
||
|
previous_group = group
|
||
|
end
|
||
|
|
||
|
# fetch row values
|
||
|
col_values = fetch_row_values(issue, query, level)
|
||
|
|
||
|
# make new page if it doesn't fit on the current one
|
||
|
base_y = pdf.get_y
|
||
|
max_height = get_issues_to_pdf_write_cells(pdf, col_values, col_width)
|
||
| ... | ... | |
|
render_table_header(pdf, query, col_width, row_height, table_width)
|
||
|
base_y = pdf.get_y
|
||
|
end
|
||
|
|
||
|
# write the cells on page
|
||
|
issues_to_pdf_write_cells(pdf, col_values, col_width, max_height)
|
||
|
pdf.set_y(base_y + max_height)
|
||
|
|
||
|
if query.has_column?(:description) && issue.description?
|
||
|
pdf.set_x(10)
|
||
|
pdf.set_auto_page_break(true, bottom_margin)
|
||
|
pdf.RDMwriteHTMLCell(0, 5, 10, '', issue.description.to_s, issue.attachments, "LRBT")
|
||
|
pdf.set_auto_page_break(false)
|
||
|
end
|
||
|
if query.has_column?(:last_notes) && issue.last_notes.present?
|
||
|
pdf.set_x(10)
|
||
|
pdf.set_auto_page_break(true, bottom_margin)
|
||
|
pdf.RDMwriteHTMLCell(0, 5, 10, '', issue.last_notes.to_s, [], "LRBT")
|
||
|
pdf.set_auto_page_break(false)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if issues.size == Setting.issues_export_limit.to_i
|
||
|
pdf.SetFontStyle('B',10)
|
||
|
pdf.RDMCell(0, row_height, '...')
|
||
| public/stylesheets/application.css | ||
|---|---|---|
|
tr.issue td.relations { text-align: left; }
|
||
|
tr.issue td.done_ratio table.progress { margin-left:auto; margin-right: auto;}
|
||
|
tr.issue td.relations span {white-space: nowrap;}
|
||
|
table.issues td.description {color:#777; font-size:90%; padding:4px 4px 4px 24px; text-align:left; white-space:normal;}
|
||
|
table.issues td.description pre {white-space:normal;}
|
||
|
table.issues td.description, table.issues td.last_notes {color:#777; font-size:90%; padding:4px 4px 4px 24px; text-align:left; white-space:normal;}
|
||
|
table.issues td.description pre, table.issues td.last_notes pre {white-space:normal;}
|
||
|
tr.issue.idnt td.subject {background: url(../images/bullet_arrow_right.png) no-repeat 0 50%;}
|
||
|
tr.issue.idnt-1 td.subject {padding-left: 24px; background-position: 8px 50%;}
|
||
| test/functional/issues_controller_test.rb | ||
|---|---|---|
|
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5')
|
||
|
issue = Issue.generate!(:subject => str_utf8)
|
||
|
get :index, :project_id => 1,
|
||
|
:f => ['subject'],
|
||
|
get :index, :project_id => 1,
|
||
|
:f => ['subject'],
|
||
|
:op => '=', :values => [str_utf8],
|
||
|
:format => 'csv'
|
||
|
assert_equal 'text/csv; header=present', @response.content_type
|
||
| ... | ... | |
|
str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
|
||
|
issue = Issue.generate!(:subject => str_utf8)
|
||
|
get :index, :project_id => 1,
|
||
|
:f => ['subject'],
|
||
|
get :index, :project_id => 1,
|
||
|
:f => ['subject'],
|
||
|
:op => '=', :values => [str_utf8],
|
||
|
:c => ['status', 'subject'],
|
||
|
:format => 'csv',
|
||
| ... | ... | |
|
str1 = "test_index_csv_tw"
|
||
|
issue = Issue.generate!(:subject => str1, :estimated_hours => '1234.5')
|
||
|
get :index, :project_id => 1,
|
||
|
:f => ['subject'],
|
||
|
get :index, :project_id => 1,
|
||
|
:f => ['subject'],
|
||
|
:op => '=', :values => [str1],
|
||
|
:c => ['estimated_hours', 'subject'],
|
||
|
:format => 'csv',
|
||
| ... | ... | |
|
str1 = "test_index_csv_fr"
|
||
|
issue = Issue.generate!(:subject => str1, :estimated_hours => '1234.5')
|
||
|
get :index, :project_id => 1,
|
||
|
:f => ['subject'],
|
||
|
get :index, :project_id => 1,
|
||
|
:f => ['subject'],
|
||
|
:op => '=', :values => [str1],
|
||
|
:c => ['estimated_hours', 'subject'],
|
||
|
:format => 'csv',
|
||
| ... | ... | |
|
assert_response :success
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def test_index_sort_by_assigned_to
|
||
|
get :index, :sort => 'assigned_to'
|
||
|
assert_response :success
|
||
|
|
||
|
assignees = issues_in_list.map(&:assigned_to).compact
|
||
|
assert_equal assignees.sort, assignees
|
||
|
assert_select 'table.issues.sort-by-assigned-to.sort-asc'
|
||
|
end
|
||
|
|
||
|
def test_index_sort_by_assigned_to_desc
|
||
|
get :index, :sort => 'assigned_to:desc'
|
||
|
assert_response :success
|
||
|
|
||
|
assignees = issues_in_list.map(&:assigned_to).compact
|
||
|
assert_equal assignees.sort.reverse, assignees
|
||
|
assert_select 'table.issues.sort-by-assigned-to.sort-desc'
|
||
|
end
|
||
|
|
||
|
def test_index_group_by_assigned_to
|
||
|
get :index, :group_by => 'assigned_to', :sort => 'priority'
|
||
|
assert_response :success
|
||
|
end
|
||
|
|
||
|
def test_index_sort_by_author
|
||
|
get :index, :sort => 'author', :c => ['author']
|
||
|
assert_response :success
|
||
|
|
||
|
authors = issues_in_list.map(&:author)
|
||
|
assert_equal authors.sort, authors
|
||
|
end
|
||
| ... | ... | |
|
def test_index_sort_by_author_desc
|
||
|
get :index, :sort => 'author:desc'
|
||
|
assert_response :success
|
||
|
|
||
|
authors = issues_in_list.map(&:author)
|
||
|
assert_equal authors.sort.reverse, authors
|
||
|
end
|
||
|
|
||
|
def test_index_group_by_author
|
||
|
get :index, :group_by => 'author', :sort => 'priority'
|
||
|
assert_response :success
|
||
|
end
|
||
|
|
||
|
def test_index_sort_by_spent_hours
|
||
|
get :index, :sort => 'spent_hours:desc'
|
||
|
assert_response :success
|
||
|
hours = issues_in_list.map(&:spent_hours)
|
||
|
assert_equal hours.sort.reverse, hours
|
||
|
end
|
||
|
|
||
|
def test_index_sort_by_total_spent_hours
|
||
|
get :index, :sort => 'total_spent_hours:desc'
|
||
|
assert_response :success
|
||
|
hours = issues_in_list.map(&:total_spent_hours)
|
||
|
assert_equal hours.sort.reverse, hours
|
||
|
end
|
||
|
|
||
|
def test_index_sort_by_total_estimated_hours
|
||
|
get :index, :sort => 'total_estimated_hours:desc'
|
||
|
assert_response :success
|
||
| ... | ... | |
|
assert_equal 'application/pdf', response.content_type
|
||
|
end
|
||
|
def test_index_with_last_notes_column
|
||
|
get :index, :set_filter => 1, :c => %w(subject last_notes)
|
||
|
assert_response :success
|
||
|
assert_select 'table.issues thead th', 3 # columns: chekbox + id + subject
|
||
|
assert_select 'td.last_notes[colspan="3"]', :text => 'Some notes with Redmine links: #2, r2.'
|
||
|
assert_select 'td.last_notes[colspan="3"]', :text => 'A comment with inline image: and a reference to #1 and r2.'
|
||
|
get :index, :set_filter => 1, :c => %w(subject last_notes), :format => 'pdf'
|
||
|
assert_response :success
|
||
|
assert_equal 'application/pdf', response.content_type
|
||
|
end
|
||
|
def test_index_with_last_notes_column_should_display_private_notes_with_permission_only
|
||
|
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Privates notes', :private_notes => true, :user_id => 1)
|
||
|
@request.session[:user_id] = 2
|
||
|
get :index, :set_filter => 1, :c => %w(subject last_notes)
|
||
|
assert_response :success
|
||
|
assert_select 'td.last_notes[colspan="3"]', :text => 'Privates notes'
|
||
|
Role.find(1).remove_permission! :view_private_notes
|
||
|
get :index, :set_filter => 1, :c => %w(subject last_notes)
|
||
|
assert_response :success
|
||
|
assert_select 'td.last_notes[colspan="3"]', :text => 'A comment with inline image: and a reference to #1 and r2.'
|
||
|
end
|
||
|
def test_index_with_description_and_last_notes_columns_should_display_column_name
|
||
|
get :index, :set_filter => 1, :c => %w(subject last_notes description)
|
||
|
assert_response :success
|
||
|
assert_select 'td.last_notes[colspan="3"] span', :text => 'Last notes'
|
||
|
assert_select 'td.description[colspan="3"] span', :text => 'Description'
|
||
|
end
|
||
|
def test_index_with_parent_column
|
||
|
Issue.delete_all
|
||
|
parent = Issue.generate!
|
||
| ... | ... | |
|
def test_index_should_not_include_new_issue_tab_for_project_without_trackers
|
||
|
with_settings :new_item_menu_tab => '1' do
|
||
|
Project.find(1).trackers.clear
|
||
|
|
||
|
@request.session[:user_id] = 2
|
||
|
get :index, :project_id => 1
|
||
|
assert_select '#main-menu a.new-issue', 0
|
||
| ... | ... | |
|
role = Role.find(1)
|
||
|
role.remove_permission! :add_issues
|
||
|
role.add_permission! :copy_issues
|
||
|
|
||
|
@request.session[:user_id] = 2
|
||
|
get :index, :project_id => 1
|
||
|
assert_select '#main-menu a.new-issue', 0
|
||
| ... | ... | |
|
def test_show_should_display_prev_next_links_with_query_and_sort_on_association
|
||
|
@request.session[:issue_query] = {:filters => {'status_id' => {:values => [''], :operator => 'o'}}, :project_id => nil}
|
||
|
|
||
|
%w(project tracker status priority author assigned_to category fixed_version).each do |assoc_sort|
|
||
|
@request.session['issues_index_sort'] = assoc_sort
|
||
| ... | ... | |
|
end
|
||
|
def test_show_export_to_pdf
|
||
|
issue = Issue.find(3)
|
||
|
issue = Issue.find(3)
|
||
|
assert issue.relations.select{|r| r.other_issue(issue).visible?}.present?
|
||
|
get :show, :id => 3, :format => 'pdf'
|
||
|
assert_response :success
|
||
| ... | ... | |
|
get :new, :project_id => 'invalid'
|
||
|
assert_response 404
|
||
|
end
|
||
|
|
||
|
def test_new_with_parent_id_should_only_propose_valid_trackers
|
||
|
@request.session[:user_id] = 2
|
||
|
t = Tracker.find(3)
|
||
| ... | ... | |
|
:custom_field_values => {'2' => 'Value for field 2'}}
|
||
|
end
|
||
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => Issue.last.id
|
||
|
|
||
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
assert_select 'option[value="1"][selected=selected]', :text => 'eCookbook'
|
||
|
assert_select 'option[value="2"]:not([selected])', :text => 'OnlineStore'
|
||
|
end
|
||
|
assert_select 'input[name=?][value=?]', 'issue[subject]', orig.subject
|
||
|
assert_select 'input[name=?][value=?]', 'issue[subject]', orig.subject
|
||
|
assert_select 'input[name=copy_from][value="1"]'
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
def test_get_edit_should_display_the_time_entry_form_with_log_time_permission
|
||
|
@request.session[:user_id] = 2
|
||
|
Role.find_by_name('Manager').update_attribute :permissions, [:view_issues, :edit_issues, :log_time]
|
||
|
|
||
|
get :edit, :id => 1
|
||
|
assert_select 'input[name=?]', 'time_entry[hours]'
|
||
|
end
|
||
| ... | ... | |
|
def test_get_edit_should_not_display_the_time_entry_form_without_log_time_permission
|
||
|
@request.session[:user_id] = 2
|
||
|
Role.find_by_name('Manager').remove_permission! :log_time
|
||
|
|
||
|
get :edit, :id => 1
|
||
|
assert_select 'input[name=?]', 'time_entry[hours]', 0
|
||
|
end
|
||
| ... | ... | |
|
assert_response :redirect
|
||
|
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue.id
|
||
|
end
|
||
|
|
||
|
def test_put_update_should_redirect_with_previous_and_next_issue_ids_params
|
||
|
@request.session[:user_id] = 2
|
||
| ... | ... | |
|
assert_select 'select[name=?]', 'issue[project_id]'
|
||
|
assert_select 'input[name=?]', 'issue[parent_issue_id]'
|
||
|
|
||
|
# Project specific custom field, date type
|
||
|
field = CustomField.find(9)
|
||
|
assert !field.is_for_all?
|
||
|
assert_equal 'date', field.field_format
|
||
|
assert_select 'input[name=?]', 'issue[custom_field_values][9]'
|
||
|
|
||
|
# System wide custom field
|
||
|
assert CustomField.find(1).is_for_all?
|
||
|
assert_select 'select[name=?]', 'issue[custom_field_values][1]'
|
||
|
|
||
|
# Be sure we don't display inactive IssuePriorities
|
||
|
assert ! IssuePriority.find(15).active?
|
||
|
assert_select 'select[name=?]', 'issue[priority_id]' do
|
||
| ... | ... | |
|
:issue => {:priority_id => '',
|
||
|
:assigned_to_id => group.id,
|
||
|
:custom_field_values => {'2' => ''}}
|
||
|
|
||
|
assert_response 302
|
||
|
assert_equal [group, group], Issue.where(:id => [1, 2]).collect {|i| i.assigned_to}
|
||
|
end
|
||
| ... | ... | |
|
assert_select 'option[value="2"]'
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def test_bulk_copy_to_another_project
|
||
|
@request.session[:user_id] = 2
|
||
|
assert_difference 'Issue.count', 2 do
|
||
| ... | ... | |
|
:assigned_to_id => 2)
|
||
|
]
|
||
|
assert_difference 'Issue.count', issues.size do
|
||
|
post :bulk_update, :ids => issues.map(&:id), :copy => '1',
|
||
|
post :bulk_update, :ids => issues.map(&:id), :copy => '1',
|
||
|
:issue => {
|
||
|
:project_id => '', :tracker_id => '', :assigned_to_id => '',
|
||
|
:status_id => '', :start_date => '', :due_date => ''
|
||
| ... | ... | |
|
@request.session[:user_id] = 2
|
||
|
assert_difference 'Issue.count', 2 do
|
||
|
assert_no_difference 'Project.find(1).issues.count' do
|
||
|
post :bulk_update, :ids => [1, 2], :copy => '1',
|
||
|
post :bulk_update, :ids => [1, 2], :copy => '1',
|
||
|
:issue => {
|
||
|
:project_id => '2', :tracker_id => '', :assigned_to_id => '2',
|
||
|
:status_id => '1', :start_date => '2009-12-01', :due_date => '2009-12-31'
|
||
| test/unit/query_test.rb | ||
|---|---|---|
|
Member.create!(:project_id => 1, :principal => other_group, :role_ids => [1])
|
||
|
User.current = user
|
||
|
with_settings :issue_group_assignment => '1' do
|
||
|
with_settings :issue_group_assignment => '1' do
|
||
|
i1 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => user)
|
||
|
i2 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => group)
|
||
|
i3 = Issue.generate!(:project_id => 1, :tracker_id => 1, :assigned_to => other_group)
|
||
|
|
||
|
query = IssueQuery.new(:name => '_', :filters => { 'assigned_to_id' => {:operator => '=', :values => ['me']}})
|
||
|
result = query.issues
|
||
|
assert_equal Issue.visible.where(:assigned_to_id => ([2] + user.reload.group_ids)).sort_by(&:id), result.sort_by(&:id)
|
||
|
|
||
|
assert result.include?(i1)
|
||
|
assert result.include?(i2)
|
||
|
assert !result.include?(i3)
|
||
| ... | ... | |
|
def test_inline_and_block_columns
|
||
|
q = IssueQuery.new
|
||
|
q.column_names = ['subject', 'description', 'tracker']
|
||
|
q.column_names = ['subject', 'description', 'tracker', 'last_notes']
|
||
|
assert_equal [:id, :subject, :tracker], q.inline_columns.map(&:name)
|
||
|
assert_equal [:description], q.block_columns.map(&:name)
|
||
|
assert_equal [:description, :last_notes], q.block_columns.map(&:name)
|
||
|
end
|
||
|
def test_custom_field_columns_should_be_inline
|
||
| ... | ... | |
|
assert_not_nil issues.first.instance_variable_get("@spent_hours")
|
||
|
end
|
||
|
def test_query_should_preload_last_notes
|
||
|
q = IssueQuery.new(:name => '_', :column_names => [:subject, :last_notes])
|
||
|
assert q.has_column?(:last_notes)
|
||
|
issues = q.issues
|
||
|
assert_not_nil issues.first.instance_variable_get("@last_notes")
|
||
|
end
|
||
|
def test_groupable_columns_should_include_custom_fields
|
||
|
q = IssueQuery.new
|
||
|
column = q.groupable_columns.detect {|c| c.name == :cf_1}
|
||