Commit 8e3d1b69 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Adds subtasking (#443) including:

* priority, start/due dates, progress, estimate, spent time roll-up to parent issues
* descendant issues tree displayed on the issue view with context menu support
* issue tree display on the gantt chart
* issue tree copy on project copy
* unlimited nesting

Defining subtasks requires the new permission 'Manage subtasks'.
Subtasks can not belong to a different project than the parent task.

Implementation is based on scoped nested sets for fast reads and updates.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3573 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent e109c9b6
...@@ -21,7 +21,7 @@ class IssuesController < ApplicationController ...@@ -21,7 +21,7 @@ class IssuesController < ApplicationController
before_filter :find_issue, :only => [:show, :edit, :update, :reply] before_filter :find_issue, :only => [:show, :edit, :update, :reply]
before_filter :find_issues, :only => [:bulk_edit, :move, :destroy] before_filter :find_issues, :only => [:bulk_edit, :move, :destroy]
before_filter :find_project, :only => [:new, :update_form, :preview] before_filter :find_project, :only => [:new, :update_form, :preview, :auto_complete]
before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :context_menu] before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :context_menu]
before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar] before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar]
accept_key_auth :index, :show, :changes accept_key_auth :index, :show, :changes
...@@ -164,7 +164,8 @@ class IssuesController < ApplicationController ...@@ -164,7 +164,8 @@ class IssuesController < ApplicationController
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue}) call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
respond_to do |format| respond_to do |format|
format.html { format.html {
redirect_to(params[:continue] ? { :action => 'new', :tracker_id => @issue.tracker } : redirect_to(params[:continue] ? { :action => 'new', :issue => {:tracker_id => @issue.tracker,
:parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
{ :action => 'show', :id => @issue }) { :action => 'show', :id => @issue })
} }
format.xml { render :action => 'show', :status => :created, :location => url_for(:controller => 'issues', :action => 'show', :id => @issue) } format.xml { render :action => 'show', :status => :created, :location => url_for(:controller => 'issues', :action => 'show', :id => @issue) }
...@@ -247,6 +248,7 @@ class IssuesController < ApplicationController ...@@ -247,6 +248,7 @@ class IssuesController < ApplicationController
# Bulk edit a set of issues # Bulk edit a set of issues
def bulk_edit def bulk_edit
@issues.sort!
if request.post? if request.post?
attributes = (params[:issue] || {}).reject {|k,v| v.blank?} attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
...@@ -254,6 +256,7 @@ class IssuesController < ApplicationController ...@@ -254,6 +256,7 @@ class IssuesController < ApplicationController
unsaved_issue_ids = [] unsaved_issue_ids = []
@issues.each do |issue| @issues.each do |issue|
issue.reload
journal = issue.init_journal(User.current, params[:notes]) journal = issue.init_journal(User.current, params[:notes])
issue.safe_attributes = attributes issue.safe_attributes = attributes
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
...@@ -271,6 +274,7 @@ class IssuesController < ApplicationController ...@@ -271,6 +274,7 @@ class IssuesController < ApplicationController
end end
def move def move
@issues.sort!
@copy = params[:copy_options] && params[:copy_options][:copy] @copy = params[:copy_options] && params[:copy_options][:copy]
@allowed_projects = [] @allowed_projects = []
# find projects to which the user is allowed to move the issue # find projects to which the user is allowed to move the issue
...@@ -289,6 +293,7 @@ class IssuesController < ApplicationController ...@@ -289,6 +293,7 @@ class IssuesController < ApplicationController
unsaved_issue_ids = [] unsaved_issue_ids = []
moved_issues = [] moved_issues = []
@issues.each do |issue| @issues.each do |issue|
issue.reload
changed_attributes = {} changed_attributes = {}
[:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute| [:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute|
unless params[valid_attribute].blank? unless params[valid_attribute].blank?
...@@ -297,7 +302,7 @@ class IssuesController < ApplicationController ...@@ -297,7 +302,7 @@ class IssuesController < ApplicationController
end end
issue.init_journal(User.current) issue.init_journal(User.current)
call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy }) call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy })
if r = issue.move_to(@target_project, new_tracker, {:copy => @copy, :attributes => changed_attributes}) if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => changed_attributes})
moved_issues << r moved_issues << r
else else
unsaved_issue_ids << issue.id unsaved_issue_ids << issue.id
...@@ -456,6 +461,18 @@ class IssuesController < ApplicationController ...@@ -456,6 +461,18 @@ class IssuesController < ApplicationController
render :partial => 'common/preview' render :partial => 'common/preview'
end end
def auto_complete
@issues = []
q = params[:q].to_s
if q.match(/^\d+$/)
@issues << @project.issues.visible.find_by_id(q.to_i)
end
unless q.blank?
@issues += @project.issues.visible.find(:all, :conditions => ["LOWER(#{Issue.table_name}.subject) LIKE ?", "%#{q.downcase}%"], :limit => 10)
end
render :layout => false
end
private private
def find_issue def find_issue
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
......
...@@ -94,7 +94,7 @@ class TimelogController < ApplicationController ...@@ -94,7 +94,7 @@ class TimelogController < ApplicationController
elsif @issue.nil? elsif @issue.nil?
sql_condition = @project.project_condition(Setting.display_subprojects_issues?) sql_condition = @project.project_condition(Setting.display_subprojects_issues?)
else else
sql_condition = "#{TimeEntry.table_name}.issue_id = #{@issue.id}" sql_condition = "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}"
end end
sql = "SELECT #{sql_select}, tyear, tmonth, tweek, spent_on, SUM(hours) AS hours" sql = "SELECT #{sql_select}, tyear, tmonth, tweek, spent_on, SUM(hours) AS hours"
...@@ -166,7 +166,7 @@ class TimelogController < ApplicationController ...@@ -166,7 +166,7 @@ class TimelogController < ApplicationController
elsif @issue.nil? elsif @issue.nil?
cond << @project.project_condition(Setting.display_subprojects_issues?) cond << @project.project_condition(Setting.display_subprojects_issues?)
else else
cond << ["#{TimeEntry.table_name}.issue_id = ?", @issue.id] cond << "#{Issue.table_name}.root_id = #{@issue.root_id} AND #{Issue.table_name}.lft >= #{@issue.lft} AND #{Issue.table_name}.rgt <= #{@issue.rgt}"
end end
retrieve_date_range retrieve_date_range
...@@ -176,7 +176,7 @@ class TimelogController < ApplicationController ...@@ -176,7 +176,7 @@ class TimelogController < ApplicationController
respond_to do |format| respond_to do |format|
format.html { format.html {
# Paginate results # Paginate results
@entry_count = TimeEntry.count(:include => :project, :conditions => cond.conditions) @entry_count = TimeEntry.count(:include => [:project, :issue], :conditions => cond.conditions)
@entry_pages = Paginator.new self, @entry_count, per_page_option, params['page'] @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page']
@entries = TimeEntry.find(:all, @entries = TimeEntry.find(:all,
:include => [:project, :activity, :user, {:issue => :tracker}], :include => [:project, :activity, :user, {:issue => :tracker}],
...@@ -184,7 +184,7 @@ class TimelogController < ApplicationController ...@@ -184,7 +184,7 @@ class TimelogController < ApplicationController
:order => sort_clause, :order => sort_clause,
:limit => @entry_pages.items_per_page, :limit => @entry_pages.items_per_page,
:offset => @entry_pages.current.offset) :offset => @entry_pages.current.offset)
@total_hours = TimeEntry.sum(:hours, :include => :project, :conditions => cond.conditions).to_f @total_hours = TimeEntry.sum(:hours, :include => [:project, :issue], :conditions => cond.conditions).to_f
render :layout => !request.xhr? render :layout => !request.xhr?
} }
......
...@@ -30,6 +30,34 @@ module IssuesHelper ...@@ -30,6 +30,34 @@ module IssuesHelper
"<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" + "<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
"<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}" "<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}"
end end
def render_issue_subject_with_tree(issue)
s = ''
issue.ancestors.each do |ancestor|
s << '<div>' + content_tag('p', link_to_issue(ancestor))
end
s << '<div>' + content_tag('h3', h(issue.subject))
s << '</div>' * (issue.ancestors.size + 1)
s
end
def render_descendants_tree(issue)
s = '<form><table class="list issues">'
ancestors = []
issue.descendants.sort_by(&:lft).each do |child|
level = child.level - issue.level - 1
s << content_tag('tr',
content_tag('td', check_box_tag("ids[]", child.id, false, :id => nil)) +
content_tag('td', link_to_issue(child), :class => 'subject',
:style => "padding-left: #{level * 20}px") +
content_tag('td', h(child.status)) +
content_tag('td', link_to_user(child.assigned_to)) +
content_tag('td', progress_bar(child.done_ratio, :width => '80px')),
:class => "issue-#{child.id} hascontextmenu")
end
s << '</form></table>'
s
end
def render_custom_fields_rows(issue) def render_custom_fields_rows(issue)
return if issue.custom_field_values.empty? return if issue.custom_field_values.empty?
......
This diff is collapsed.
...@@ -48,6 +48,7 @@ class IssueRelation < ActiveRecord::Base ...@@ -48,6 +48,7 @@ class IssueRelation < ActiveRecord::Base
errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations? errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations?
errors.add_to_base :circular_dependency if issue_to.all_dependent_issues.include? issue_from errors.add_to_base :circular_dependency if issue_to.all_dependent_issues.include? issue_from
errors.add_to_base :cant_link_an_issue_with_a_descendant if issue_from.is_descendant_of?(issue_to) || issue_from.is_ancestor_of?(issue_to)
end end
end end
......
...@@ -557,9 +557,12 @@ class Project < ActiveRecord::Base ...@@ -557,9 +557,12 @@ class Project < ActiveRecord::Base
# value. Used to map the two togeather for issue relations. # value. Used to map the two togeather for issue relations.
issues_map = {} issues_map = {}
project.issues.each do |issue| # Get issues sorted by root_id, lft so that parent issues
# get copied before their children
project.issues.find(:all, :order => 'root_id, lft').each do |issue|
new_issue = Issue.new new_issue = Issue.new
new_issue.copy_from(issue) new_issue.copy_from(issue)
new_issue.project = self
# Reassign fixed_versions by name, since names are unique per # Reassign fixed_versions by name, since names are unique per
# project and the versions for self are not yet saved # project and the versions for self are not yet saved
if issue.fixed_version if issue.fixed_version
...@@ -570,6 +573,13 @@ class Project < ActiveRecord::Base ...@@ -570,6 +573,13 @@ class Project < ActiveRecord::Base
if issue.category if issue.category
new_issue.category = self.issue_categories.select {|c| c.name == issue.category.name}.first new_issue.category = self.issue_categories.select {|c| c.name == issue.category.name}.first
end end
# Parent issue
if issue.parent_id
if copied_parent = issues_map[issue.parent_id]
new_issue.parent_issue_id = copied_parent.id
end
end
self.issues << new_issue self.issues << new_issue
issues_map[issue.id] = new_issue issues_map[issue.id] = new_issue
end end
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<p><label><%= l(:field_status) %></label> <%= @issue.status.name %></p> <p><label><%= l(:field_status) %></label> <%= @issue.status.name %></p>
<% end %> <% end %>
<p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p> <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), {:required => true}, :disabled => !@issue.leaf? %></p>
<p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p> <p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p>
<% unless @project.issue_categories.empty? %> <% unless @project.issue_categories.empty? %>
<p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %> <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
</div> </div>
<div class="splitcontentright"> <div class="splitcontentright">
<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p> <p><%= f.text_field :start_date, :size => 10, :disabled => !@issue.leaf? %><%= calendar_for('issue_start_date') if @issue.leaf? %></p>
<p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p> <p><%= f.text_field :due_date, :size => 10, :disabled => !@issue.leaf? %><%= calendar_for('issue_due_date') if @issue.leaf? %></p>
<p><%= f.text_field :estimated_hours, :size => 3 %> <%= l(:field_hours) %></p> <p><%= f.text_field :estimated_hours, :size => 3, :disabled => !@issue.leaf? %> <%= l(:field_hours) %></p>
<% if Issue.use_field_for_done_ratio? %> <% if @issue.leaf? && Issue.use_field_for_done_ratio? %>
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p> <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
<% end %> <% end %>
</div> </div>
......
...@@ -5,6 +5,16 @@ ...@@ -5,6 +5,16 @@
:with => "Form.serialize('issue-form')" %> :with => "Form.serialize('issue-form')" %>
<p><%= f.text_field :subject, :size => 80, :required => true %></p> <p><%= f.text_field :subject, :size => 80, :required => true %></p>
<% unless (@issue.new_record? && @issue.parent_issue_id.nil?) || !User.current.allowed_to?(:manage_subtasks, @project) %>
<p><%= f.text_field :parent_issue_id, :size => 10 %></p>
<div id="parent_issue_candidates" class="autocomplete"></div>
<%= javascript_tag "observeParentIssueField('#{url_for(:controller => :issues,
:action => :auto_complete,
:id => @issue,
:project_id => @project) }')" %>
<% end %>
<p><%= f.text_area :description, <p><%= f.text_area :description,
:cols => 60, :cols => 60,
:rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min), :rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min),
......
<ul>
<% if @issues.any? -%>
<% @issues.each do |issue| -%>
<%= content_tag 'li', h("#{issue.tracker} ##{issue.id}: #{issue.subject}"), :id => issue.id %>
<% end -%>
<% else -%>
<%= content_tag("li", l(:label_none), :style => 'display:none') %>
<% end -%>
</ul>
...@@ -79,8 +79,10 @@ t_height = g_height + headers_height ...@@ -79,8 +79,10 @@ t_height = g_height + headers_height
# Tasks subjects # Tasks subjects
# #
top = headers_height + 8 top = headers_height + 8
@gantt.events.each do |i| %> @gantt.events.each do |i|
<div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small> left = 4 + (i.is_a?(Issue) ? i.level * 16 : 0)
%>
<div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:<%= left %>px;overflow:hidden;"><small>
<% if i.is_a? Issue %> <% if i.is_a? Issue %>
<%= h("#{i.project} -") unless @project && @project == i.project %> <%= h("#{i.project} -") unless @project && @project == i.project %>
<%= link_to_issue i %> <%= link_to_issue i %>
...@@ -189,15 +191,16 @@ top = headers_height + 10 ...@@ -189,15 +191,16 @@ top = headers_height + 10
i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders) i_width = ((i_end_date - i_start_date + 1)*zoom).floor - 2 # total width of the issue (- 2 for left and right borders)
d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width d_width = ((i_done_date - i_start_date)*zoom).floor - 2 # done width
l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width l_width = i_late_date ? ((i_late_date - i_start_date+1)*zoom).floor - 2 : 0 # delay width
css = "task " + (i.leaf? ? 'leaf' : 'parent')
%> %>
<div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="task task_todo">&nbsp;</div> <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;" class="<%= css %> task_todo"><div class="left"></div>&nbsp;<div class="right"></div></div>
<% if l_width > 0 %> <% if l_width > 0 %>
<div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="task task_late">&nbsp;</div> <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= l_width %>px;" class="<%= css %> task_late">&nbsp;</div>
<% end %> <% end %>
<% if d_width > 0 %> <% if d_width > 0 %>
<div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="task task_done">&nbsp;</div> <div style="top:<%= top %>px;left:<%= i_left %>px;width:<%= d_width %>px;" class="<%= css %> task_done">&nbsp;</div>
<% end %> <% end %>
<div style="top:<%= top %>px;left:<%= i_left + i_width + 5 %>px;background:#fff;" class="task"> <div style="top:<%= top %>px;left:<%= i_left + i_width + 8 %>px;background:#fff;" class="<%= css %>">
<%= i.status.name %> <%= i.status.name %>
<%= (i.done_ratio).to_i %>% <%= (i.done_ratio).to_i %>%
</div> </div>
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
<div class="<%= @issue.css_classes %> details"> <div class="<%= @issue.css_classes %> details">
<%= avatar(@issue.author, :size => "50") %> <%= avatar(@issue.author, :size => "50") %>
<h3><%=h @issue.subject %></h3>
<div class="subject">
<%= render_issue_subject_with_tree(@issue) %>
</div>
<p class="author"> <p class="author">
<%= authoring @issue.created_on, @issue.author %>. <%= authoring @issue.created_on, @issue.author %>.
<% if @issue.created_on != @issue.updated_on %> <% if @issue.created_on != @issue.updated_on %>
...@@ -56,6 +59,17 @@ ...@@ -56,6 +59,17 @@
<%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %> <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %>
<% if !@issue.leaf? || User.current.allowed_to?(:manage_subtasks, @project) %>
<hr />
<div id="issue_tree">
<div class="contextual">
<%= link_to(l(:button_add), {:controller => 'issues', :action => 'new', :project_id => @project, :issue => {:parent_issue_id => @issue}}) if User.current.allowed_to?(:manage_subtasks, @project) %>
</div>
<p><strong><%=l(:label_subtask_pural)%></strong></p>
<%= render_descendants_tree(@issue) unless @issue.leaf? %>
</div>
<% end %>
<% if authorize_for('issue_relations', 'new') || @issue.relations.any? %> <% if authorize_for('issue_relations', 'new') || @issue.relations.any? %>
<hr /> <hr />
<div id="relations"> <div id="relations">
...@@ -113,4 +127,8 @@ ...@@ -113,4 +127,8 @@
<% content_for :header_tags do %> <% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %> <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
<%= stylesheet_link_tag 'scm' %> <%= stylesheet_link_tag 'scm' %>
<%= javascript_include_tag 'context_menu' %>
<%= stylesheet_link_tag 'context_menu' %>
<% end %> <% end %>
<div id="context-menu" style="display: none;"></div>
<%= javascript_tag "new ContextMenu('#{url_for(:controller => 'issues', :action => 'context_menu')}')" %>
\ No newline at end of file
...@@ -112,6 +112,7 @@ en: ...@@ -112,6 +112,7 @@ en:
greater_than_start_date: "must be greater than start date" greater_than_start_date: "must be greater than start date"
not_same_project: "doesn't belong to the same project" not_same_project: "doesn't belong to the same project"
circular_dependency: "This relation would create a circular dependency" circular_dependency: "This relation would create a circular dependency"
cant_link_an_issue_with_a_descendant: "An issue can not be linked to one of its subtasks"
actionview_instancetag_blank_option: Please select actionview_instancetag_blank_option: Please select
...@@ -277,6 +278,7 @@ en: ...@@ -277,6 +278,7 @@ en:
field_content: Content field_content: Content
field_group_by: Group results by field_group_by: Group results by
field_sharing: Sharing field_sharing: Sharing
field_parent_issue: Parent task
setting_app_title: Application title setting_app_title: Application title
setting_app_subtitle: Application subtitle setting_app_subtitle: Application subtitle
...@@ -386,6 +388,7 @@ en: ...@@ -386,6 +388,7 @@ en:
permission_delete_messages: Delete messages permission_delete_messages: Delete messages
permission_delete_own_messages: Delete own messages permission_delete_own_messages: Delete own messages
permission_export_wiki_pages: Export wiki pages permission_export_wiki_pages: Export wiki pages
permission_manage_subtasks: Manage subtasks
project_module_issue_tracking: Issue tracking project_module_issue_tracking: Issue tracking
project_module_time_tracking: Time tracking project_module_time_tracking: Time tracking
...@@ -750,6 +753,7 @@ en: ...@@ -750,6 +753,7 @@ en:
label_missing_api_access_key: Missing an API access key label_missing_api_access_key: Missing an API access key
label_api_access_key_created_on: "API access key created {{value}} ago" label_api_access_key_created_on: "API access key created {{value}} ago"
label_profile: Profile label_profile: Profile
label_subtask_plural: Subtasks
button_login: Login button_login: Login
button_submit: Submit button_submit: Submit
......
...@@ -136,6 +136,7 @@ fr: ...@@ -136,6 +136,7 @@ fr:
greater_than_start_date: "doit être postérieure à la date de début" greater_than_start_date: "doit être postérieure à la date de début"
not_same_project: "n'appartient pas au même projet" not_same_project: "n'appartient pas au même projet"
circular_dependency: "Cette relation créerait une dépendance circulaire" circular_dependency: "Cette relation créerait une dépendance circulaire"
cant_link_an_issue_with_a_descendant: "Une demande ne peut pas être liée à l'une de ses sous-tâches"
actionview_instancetag_blank_option: Choisir actionview_instancetag_blank_option: Choisir
...@@ -299,6 +300,7 @@ fr: ...@@ -299,6 +300,7 @@ fr:
field_group_by: Grouper par field_group_by: Grouper par
field_sharing: Partage field_sharing: Partage
field_active: Actif field_active: Actif
field_parent_issue: Tâche parente
setting_app_title: Titre de l'application setting_app_title: Titre de l'application
setting_app_subtitle: Sous-titre de l'application setting_app_subtitle: Sous-titre de l'application
...@@ -408,6 +410,7 @@ fr: ...@@ -408,6 +410,7 @@ fr:
permission_delete_own_messages: Supprimer ses propres messages permission_delete_own_messages: Supprimer ses propres messages
permission_export_wiki_pages: Exporter les pages permission_export_wiki_pages: Exporter les pages
permission_manage_project_activities: Gérer les activités permission_manage_project_activities: Gérer les activités
permission_manage_subtasks: Gérer les sous-tâches
project_module_issue_tracking: Suivi des demandes project_module_issue_tracking: Suivi des demandes
project_module_time_tracking: Suivi du temps passé project_module_time_tracking: Suivi du temps passé
...@@ -765,6 +768,7 @@ fr: ...@@ -765,6 +768,7 @@ fr:
label_close_versions: Fermer les versions terminées label_close_versions: Fermer les versions terminées
label_revision_id: Revision {{value}} label_revision_id: Revision {{value}}
label_profile: Profil label_profile: Profil
label_subtask_pural: Sous-tâches
button_login: Connexion button_login: Connexion
button_submit: Soumettre button_submit: Soumettre
......
class AddIssuesNestedSetsColumns < ActiveRecord::Migration
def self.up
add_column :issues, :parent_id, :integer, :default => nil
add_column :issues, :root_id, :integer, :default => nil
add_column :issues, :lft, :integer, :default => nil
add_column :issues, :rgt, :integer, :default => nil
Issue.update_all("parent_id = NULL, root_id = id, lft = 1, rgt = 2")
end
def self.down
remove_column :issues, :parent_id
remove_column :issues, :root_id
remove_column :issues, :lft
remove_column :issues, :rgt
end
end
...@@ -47,13 +47,14 @@ Redmine::AccessControl.map do |map| ...@@ -47,13 +47,14 @@ Redmine::AccessControl.map do |map|
map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member
# Issues # Issues
map.permission :view_issues, {:projects => :roadmap, map.permission :view_issues, {:projects => :roadmap,
:issues => [:index, :changes, :show, :context_menu], :issues => [:index, :changes, :show, :context_menu, :auto_complete],
:versions => [:show, :status_by], :versions => [:show, :status_by],
:queries => :index, :queries => :index,
:reports => [:issue_report, :issue_report_details]} :reports => [:issue_report, :issue_report_details]}
map.permission :add_issues, {:issues => [:new, :update_form]} map.permission :add_issues, {:issues => [:new, :update_form]}
map.permission :edit_issues, {:issues => [:edit, :update, :reply, :bulk_edit, :update_form]} map.permission :edit_issues, {:issues => [:edit, :update, :reply, :bulk_edit, :update_form]}
map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
map.permission :manage_subtasks, {}
map.permission :add_issue_notes, {:issues => [:edit, :update, :reply]} map.permission :add_issue_notes, {:issues => [:edit, :update, :reply]}
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
......
...@@ -53,6 +53,7 @@ module Redmine ...@@ -53,6 +53,7 @@ module Redmine
:add_issues, :add_issues,
:edit_issues, :edit_issues,
:manage_issue_relations, :manage_issue_relations,
:manage_subtasks,
:add_issue_notes, :add_issue_notes,
:save_queries, :save_queries,
:view_gantt, :view_gantt,
......
...@@ -52,8 +52,29 @@ module Redmine ...@@ -52,8 +52,29 @@ module Redmine
@date_to = (@date_from >> @months) - 1 @date_to = (@date_from >> @months) - 1
end end
def events=(e) def events=(e)
@events = e.sort {|x,y| x.start_date <=> y.start_date } @events = e
# Adds all ancestors
root_ids = e.select {|i| i.is_a?(Issue) && i.parent_id? }.collect(&:root_id).uniq
if root_ids.any?
# Retrieves all nodes
parents = Issue.find_all_by_root_id(root_ids, :conditions => ["rgt - lft > 1"])
# Only add ancestors
@events += parents.select {|p| @events.detect {|i| i.is_a?(Issue) && p.is_ancestor_of?(i)}}
end
@events.uniq!
# Sort issues by hierarchy and start dates
@events.sort! {|x,y|
if x.is_a?(Issue) && y.is_a?(Issue)
gantt_issue_compare(x, y, @events)
else
gantt_start_compare(x, y)
end
}
# Removes issues that have no start or end date
@events.reject! {|i| i.is_a?(Issue) && (i.start_date.nil? || i.due_before.nil?) }
@events
end end
def params def params
...@@ -218,6 +239,36 @@ module Redmine ...@@ -218,6 +239,36 @@ module Redmine
imgl.format = format imgl.format = format
imgl.to_blob imgl.to_blob
end if Object.const_defined?(:Magick) end if Object.const_defined?(:Magick)
private
def gantt_issue_compare(x, y, issues)
if x.parent_id == y.parent_id
gantt_start_compare(x, y)
elsif x.is_ancestor_of?(y)
-1
elsif y.is_ancestor_of?(x)
1
else
ax = issues.select {|i| i.is_a?(Issue) && i.is_ancestor_of?(x) && !i.is_ancestor_of?(y) }.sort_by(&:lft).first
ay = issues.select {|i| i.is_a?(Issue) && i.is_ancestor_of?(y) && !i.is_ancestor_of?(x) }.sort_by(&:lft).first
if ax.nil? && ay.nil?
gantt_start_compare(x, y)
else
gantt_issue_compare(ax || x, ay || y, issues)
end
end
end
def gantt_start_compare(x, y)
if x.start_date.nil?
-1
elsif y.start_date.nil?
1
else
x.start_date <=> y.start_date
end
end
end end
end end
end end
...@@ -194,6 +194,18 @@ function randomKey(size) { ...@@ -194,6 +194,18 @@ function randomKey(size) {
return key; return key;
} }
function observeParentIssueField(url) {
new Ajax.Autocompleter('issue_parent_issue_id',
'parent_issue_candidates',
url,
{ minChars: 3,
frequency: 0.5,
paramName: 'q',
updateElement: function(value) {
document.getElementById('issue_parent_issue_id').value = value.id;
}});
}
/* shows and hides ajax indicator */ /* shows and hides ajax indicator */
Ajax.Responders.register({ Ajax.Responders.register({
onCreate: function(){ onCreate: function(){
......
...@@ -237,6 +237,13 @@ p.breadcrumb { font-size: 0.9em; margin: 4px 0 4px 0;} ...@@ -237,6 +237,13 @@ p.breadcrumb { font-size: 0.9em; margin: 4px 0 4px 0;}
p.subtitle { font-size: 0.9em; margin: -6px 0 12px 0; font-style: italic; } p.subtitle { font-size: 0.9em; margin: -6px 0 12px 0; font-style: italic; }
p.footnote { font-size: 0.9em; margin-top: 0px; margin-bottom: 0px; } p.footnote { font-size: 0.9em; margin-top: 0px; margin-bottom: 0px; }
div.issue div.subject div div { padding-left: 16px; }
div.issue div.subject p {margin: 0; margin-bottom: 0.1em; font-size: 90%; color: #999;}
div.issue div.subject>div>p { margin-top: 0.5em; }
div.issue div.subject h3 {margin: 0; margin-bottom: 0.1em;}
#issue_tree table.issues { border: 0; }
fieldset.collapsible { border-width: 1px 0 0 0; font-size: 0.9em; } fieldset.collapsible { border-width: 1px 0 0 0; font-size: 0.9em; }
fieldset.collapsible legend { padding-left: 16px; background: url(../images/arrow_expanded.png) no-repeat 0% 40%; cursor:pointer; } fieldset.collapsible legend { padding-left: 16px; background: url(../images/arrow_expanded.png) no-repeat 0% 40%; cursor:pointer; }
fieldset.collapsible.collapsed legend { background-image: url(../images/arrow_collapsed.png); } fieldset.collapsible.collapsed legend { background-image: url(../images/arrow_collapsed.png); }
...@@ -588,8 +595,7 @@ button.tab-right { ...@@ -588,8 +595,7 @@ button.tab-right {
/***** Auto-complete *****/ /***** Auto-complete *****/
div.autocomplete { div.autocomplete {
position:absolute; position:absolute;
width:250px; width:400px;
background-color:white;
margin:0; margin:0;
padding:0; padding:0;
} }
...@@ -598,23 +604,26 @@ div.autocomplete ul { ...@@ -598,23 +604,26 @@ div.autocomplete ul {
margin:0; margin:0;
padding:0; padding:0;
} }
div.autocomplete ul li.selected { background-color: #ffb;}
div.autocomplete ul li { div.autocomplete ul li {
list-style-type:none; list-style-type:none;
display:block; display:block;
margin:0; margin:-1px 0 0 0;
padding:2px; padding:2px;
cursor:pointer; cursor:pointer;
font-size: 90%; font-size: 90%;
border-bottom: 1px solid #ccc; border: 1px solid #ccc;
border-left: 1px solid #ccc; border-left: 1px solid #ccc;
border-right: 1px solid #ccc; border-right: 1px solid #ccc;
background-color:white;
} }
div.autocomplete ul li.selected { background-color: #ffb;}
div.autocomplete ul li span.informal { div.autocomplete ul li span.informal {
font-size: 80%; font-size: 80%;
color: #aaa; color: #aaa;
} }
#parent_issue_candidates ul li {width: 500px;}
/***** Diff *****/ /***** Diff *****/
.diff_out { background: #fcc; } .diff_out { background: #fcc; }
.diff_in { background: #cfc; } .diff_in { background: #cfc; }
...@@ -741,6 +750,12 @@ background-image:url('../images/close_hl.png'); ...@@ -741,6 +750,12 @@ background-image:url('../images/close_hl.png');
.task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; } .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; }
.task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; } .task_done { background:#66f url(../images/task_done.png); border: 1px solid #66f; }
.task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; } .task_todo { background:#aaa url(../images/task_todo.png); border: 1px solid #aaa; }
.task_todo.parent { background: #888; border: 1px solid #888; height: 6px;}
.task_late.parent, .task_done.parent { height: 3px;}
.task_todo.parent .left { position: absolute; background: url(../images/task_parent_end.png) no-repeat 0 0; width: 8px; height: 16px; margin-left: -5px; left: 0px; top: -1px;}
.task_todo.parent .right { position: absolute; background: url(../images/task_parent_end.png) no-repeat 0 0; width: 8px; height: 16px; margin-right: -5px; right: 0px; top: -1px;}
.milestone { background-image:url(../images/milestone.png); background-repeat: no-repeat; border: 0; } .milestone { background-image:url(../images/milestone.png); background-repeat: no-repeat; border: 0; }
/***** Icons *****/ /***** Icons *****/
......
...@@ -19,27 +19,32 @@ enumerations_004: ...@@ -19,27 +19,32 @@ enumerations_004:
id: 4 id: 4
type: IssuePriority type: IssuePriority
active: true active: true
position: 1
enumerations_005: enumerations_005:
name: Normal name: Normal
id: 5 id: 5
type: IssuePriority type: IssuePriority
is_default: true is_default: true
active: true active: true
position: 2
enumerations_006: enumerations_006:
name: High name: High
id: 6 id: 6
type: IssuePriority type: IssuePriority
active: true active: true
position: 3
enumerations_007: enumerations_007:
name: Urgent name: Urgent
id: 7 id: 7
type: IssuePriority type: IssuePriority
active: true active: true
position: 4
enumerations_008: enumerations_008:
name: Immediate name: Immediate
id: 8 id: 8
type: IssuePriority type: IssuePriority
active: true active: true
position: 5
enumerations_009: enumerations_009:
name: Design name: Design
id: 9 id: 9
......
...@@ -15,6 +15,9 @@ issues_001: ...@@ -15,6 +15,9 @@ issues_001:
status_id: 1 status_id: 1
start_date: <%= 1.day.ago.to_date.to_s(:db) %> start_date: <%= 1.day.ago.to_date.to_s(:db) %>
due_date: <%= 10.day.from_now.to_date.to_s(:db) %> due_date: <%= 10.day.from_now.to_date.to_s(:db) %>
root_id: 1
lft: 1
rgt: 2
issues_002: issues_002:
created_on: 2006-07-19 21:04:21 +02:00 created_on: 2006-07-19 21:04:21 +02:00
project_id: 1 project_id: 1
...@@ -31,6 +34,9 @@ issues_002: ...@@ -31,6 +34,9 @@ issues_002:
status_id: 2 status_id: 2
start_date: <%= 2.day.ago.to_date.to_s(:db) %> start_date: <%= 2.day.ago.to_date.to_s(:db) %>
due_date: due_date:
root_id: 2
lft: 1
rgt: 2
issues_003: issues_003:
created_on: 2006-07-19 21:07:27 +02:00 created_on: 2006-07-19 21:07:27 +02:00
project_id: 1 project_id: 1
...@@ -47,6 +53,9 @@ issues_003: ...@@ -47,6 +53,9 @@ issues_003:
status_id: 1 status_id: 1
start_date: <%= 1.day.from_now.to_date.to_s(:db) %> start_date: <%= 1.day.from_now.to_date.to_s(:db) %>
due_date: <%= 40.day.ago.to_date.to_s(:db) %> due_date: <%= 40.day.ago.to_date.to_s(:db) %>
root_id: 3
lft: 1
rgt: 2
issues_004: issues_004:
created_on: <%= 5.days.ago.to_date.to_s(:db) %> created_on: <%= 5.days.ago.to_date.to_s(:db) %>
project_id: 2 project_id: 2
...@@ -61,6 +70,9 @@ issues_004: ...@@ -61,6 +70,9 @@ issues_004:
assigned_to_id: 2 assigned_to_id: 2
author_id: 2 author_id: 2
status_id: 1 status_id: 1
root_id: 4
lft: 1
rgt: 2
issues_005: issues_005:
created_on: <%= 5.days.ago.to_date.to_s(:db) %> created_on: <%= 5.days.ago.to_date.to_s(:db) %>
project_id: 3 project_id: 3
...@@ -75,6 +87,9 @@ issues_005: ...@@ -75,6 +87,9 @@ issues_005:
assigned_to_id: assigned_to_id:
author_id: 2 author_id: 2
status_id: 1 status_id: 1
root_id: 5
lft: 1
rgt: 2
issues_006: issues_006:
created_on: <%= 1.minute.ago.to_date.to_s(:db) %> created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
project_id: 5 project_id: 5
...@@ -91,6 +106,9 @@ issues_006: ...@@ -91,6 +106,9 @@ issues_006:
status_id: 1 status_id: 1
start_date: <%= Date.today.to_s(:db) %> start_date: <%= Date.today.to_s(:db) %>
due_date: <%= 1.days.from_now.to_date.to_s(:db) %> due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
root_id: 6
lft: 1
rgt: 2
issues_007: issues_007:
created_on: <%= 10.days.ago.to_date.to_s(:db) %> created_on: <%= 10.days.ago.to_date.to_s(:db) %>
project_id: 1 project_id: 1
...@@ -108,6 +126,9 @@ issues_007: ...@@ -108,6 +126,9 @@ issues_007:
start_date: <%= 10.days.ago.to_s(:db) %> start_date: <%= 10.days.ago.to_s(:db) %>
due_date: <%= Date.today.to_s(:db) %> due_date: <%= Date.today.to_s(:db) %>
lock_version: 0 lock_version: 0
root_id: 7
lft: 1
rgt: 2
issues_008: issues_008:
created_on: <%= 10.days.ago.to_date.to_s(:db) %> created_on: <%= 10.days.ago.to_date.to_s(:db) %>
project_id: 1 project_id: 1
...@@ -125,6 +146,9 @@ issues_008: ...@@ -125,6 +146,9 @@ issues_008:
start_date: start_date:
due_date: due_date:
lock_version: 0 lock_version: 0
root_id: 8
lft: 1
rgt: 2
issues_009: issues_009:
created_on: <%= 1.minute.ago.to_date.to_s(:db) %> created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
project_id: 5 project_id: 5
...@@ -141,6 +165,9 @@ issues_009: ...@@ -141,6 +165,9 @@ issues_009:
status_id: 1 status_id: 1
start_date: <%= Date.today.to_s(:db) %> start_date: <%= Date.today.to_s(:db) %>
due_date: <%= 1.days.from_now.to_date.to_s(:db) %> due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
root_id: 9
lft: 1
rgt: 2
issues_010: issues_010:
created_on: <%= 1.minute.ago.to_date.to_s(:db) %> created_on: <%= 1.minute.ago.to_date.to_s(:db) %>
project_id: 5 project_id: 5
...@@ -157,6 +184,9 @@ issues_010: ...@@ -157,6 +184,9 @@ issues_010:
status_id: 1 status_id: 1
start_date: <%= Date.today.to_s(:db) %> start_date: <%= Date.today.to_s(:db) %>
due_date: <%= 1.days.from_now.to_date.to_s(:db) %> due_date: <%= 1.days.from_now.to_date.to_s(:db) %>
root_id: 10
lft: 1
rgt: 2
issues_011: issues_011:
created_on: <%= 3.days.ago.to_date.to_s(:db) %> created_on: <%= 3.days.ago.to_date.to_s(:db) %>
project_id: 1 project_id: 1
...@@ -173,6 +203,9 @@ issues_011: ...@@ -173,6 +203,9 @@ issues_011:
status_id: 5 status_id: 5
start_date: <%= 1.day.ago.to_date.to_s(:db) %> start_date: <%= 1.day.ago.to_date.to_s(:db) %>
due_date: due_date:
root_id: 11
lft: 1
rgt: 2
issues_012: issues_012:
created_on: <%= 3.days.ago.to_date.to_s(:db) %> created_on: <%= 3.days.ago.to_date.to_s(:db) %>
project_id: 1 project_id: 1
...@@ -189,6 +222,9 @@ issues_012: ...@@ -189,6 +222,9 @@ issues_012:
status_id: 5 status_id: 5
start_date: <%= 1.day.ago.to_date.to_s(:db) %> start_date: <%= 1.day.ago.to_date.to_s(:db) %>
due_date: due_date:
root_id: 12
lft: 1
rgt: 2
issues_013: issues_013:
created_on: <%= 5.days.ago.to_date.to_s(:db) %> created_on: <%= 5.days.ago.to_date.to_s(:db) %>
project_id: 3 project_id: 3
...@@ -203,3 +239,6 @@ issues_013: ...@@ -203,3 +239,6 @@ issues_013:
assigned_to_id: assigned_to_id:
author_id: 2 author_id: 2
status_id: 1 status_id: 1
root_id: 13
lft: 1
rgt: 2
...@@ -14,6 +14,7 @@ roles_001: ...@@ -14,6 +14,7 @@ roles_001:
- :add_issues - :add_issues
- :edit_issues - :edit_issues
- :manage_issue_relations - :manage_issue_relations
- :manage_subtasks
- :add_issue_notes - :add_issue_notes
- :move_issues - :move_issues
- :delete_issues - :delete_issues
...@@ -66,6 +67,7 @@ roles_002: ...@@ -66,6 +67,7 @@ roles_002:
- :add_issues - :add_issues
- :edit_issues - :edit_issues
- :manage_issue_relations - :manage_issue_relations
- :manage_subtasks
- :add_issue_notes - :add_issue_notes
- :move_issues - :move_issues
- :delete_issues - :delete_issues
......
...@@ -476,7 +476,7 @@ class IssuesControllerTest < ActionController::TestCase ...@@ -476,7 +476,7 @@ class IssuesControllerTest < ActionController::TestCase
:subject => 'This is first issue', :subject => 'This is first issue',
:priority_id => 5}, :priority_id => 5},
:continue => '' :continue => ''
assert_redirected_to :controller => 'issues', :action => 'new', :tracker_id => 3 assert_redirected_to :controller => 'issues', :action => 'new', :issue => {:tracker_id => 3}
end end
def test_post_new_without_custom_fields_param def test_post_new_without_custom_fields_param
...@@ -533,6 +533,20 @@ class IssuesControllerTest < ActionController::TestCase ...@@ -533,6 +533,20 @@ class IssuesControllerTest < ActionController::TestCase
assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail) assert [mail.bcc, mail.cc].flatten.include?(User.find(3).mail)
end end
def test_post_new_subissue
@request.session[:user_id] = 2
assert_difference 'Issue.count' do
post :new, :project_id => 1,
:issue => {:tracker_id => 1,
:subject => 'This is a child issue',
:parent_issue_id => 2}
end
issue = Issue.find_by_subject('This is a child issue')
assert_not_nil issue
assert_equal Issue.find(2), issue.parent
end
def test_post_new_should_send_a_notification def test_post_new_should_send_a_notification
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
@request.session[:user_id] = 2 @request.session[:user_id] = 2
...@@ -1214,6 +1228,34 @@ class IssuesControllerTest < ActionController::TestCase ...@@ -1214,6 +1228,34 @@ class IssuesControllerTest < ActionController::TestCase
:attributes => { :href => '#', :attributes => { :href => '#',
:class => 'icon-del disabled' } :class => 'icon-del disabled' }
end end
def test_auto_complete_routing
assert_routing(
{:method => :get, :path => '/issues/auto_complete'},
:controller => 'issues', :action => 'auto_complete'
)
end
def test_auto_complete_should_not_be_case_sensitive
get :auto_complete, :project_id => 'ecookbook', :q => 'ReCiPe'
assert_response :success
assert_not_nil assigns(:issues)
assert assigns(:issues).detect {|issue| issue.subject.match /recipe/}
end
def test_auto_complete_should_return_issue_with_given_id
get :auto_complete, :project_id => 'subproject1', :q => '13'
assert_response :success
assert_not_nil assigns(:issues)
assert assigns(:issues).include?(Issue.find(13))
end
def test_destroy_routing
assert_recognizes( #TODO: use DELETE on issue URI (need to change forms)
{:controller => 'issues', :action => 'destroy', :id => '1'},
{:method => :post, :path => '/issues/1/destroy'}
)
end
def test_destroy_issue_with_no_time_entries def test_destroy_issue_with_no_time_entries
assert_nil TimeEntry.find_by_issue_id(2) assert_nil TimeEntry.find_by_issue_id(2)
......
This diff is collapsed.
...@@ -329,7 +329,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -329,7 +329,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_with_same_category def test_move_to_another_project_with_same_category
issue = Issue.find(1) issue = Issue.find(1)
assert issue.move_to(Project.find(2)) assert issue.move_to_project(Project.find(2))
issue.reload issue.reload
assert_equal 2, issue.project_id assert_equal 2, issue.project_id
# Category changes # Category changes
...@@ -340,7 +340,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -340,7 +340,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_without_same_category def test_move_to_another_project_without_same_category
issue = Issue.find(2) issue = Issue.find(2)
assert issue.move_to(Project.find(2)) assert issue.move_to_project(Project.find(2))
issue.reload issue.reload
assert_equal 2, issue.project_id assert_equal 2, issue.project_id
# Category cleared # Category cleared
...@@ -350,7 +350,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -350,7 +350,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_should_clear_fixed_version_when_not_shared def test_move_to_another_project_should_clear_fixed_version_when_not_shared
issue = Issue.find(1) issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 1) issue.update_attribute(:fixed_version_id, 1)
assert issue.move_to(Project.find(2)) assert issue.move_to_project(Project.find(2))
issue.reload issue.reload
assert_equal 2, issue.project_id assert_equal 2, issue.project_id
# Cleared fixed_version # Cleared fixed_version
...@@ -360,7 +360,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -360,7 +360,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project def test_move_to_another_project_should_keep_fixed_version_when_shared_with_the_target_project
issue = Issue.find(1) issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 4) issue.update_attribute(:fixed_version_id, 4)
assert issue.move_to(Project.find(5)) assert issue.move_to_project(Project.find(5))
issue.reload issue.reload
assert_equal 5, issue.project_id assert_equal 5, issue.project_id
# Keep fixed_version # Keep fixed_version
...@@ -370,7 +370,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -370,7 +370,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project def test_move_to_another_project_should_clear_fixed_version_when_not_shared_with_the_target_project
issue = Issue.find(1) issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 1) issue.update_attribute(:fixed_version_id, 1)
assert issue.move_to(Project.find(5)) assert issue.move_to_project(Project.find(5))
issue.reload issue.reload
assert_equal 5, issue.project_id assert_equal 5, issue.project_id
# Cleared fixed_version # Cleared fixed_version
...@@ -380,7 +380,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -380,7 +380,7 @@ class IssueTest < ActiveSupport::TestCase
def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide def test_move_to_another_project_should_keep_fixed_version_when_shared_systemwide
issue = Issue.find(1) issue = Issue.find(1)
issue.update_attribute(:fixed_version_id, 7) issue.update_attribute(:fixed_version_id, 7)
assert issue.move_to(Project.find(2)) assert issue.move_to_project(Project.find(2))
issue.reload issue.reload
assert_equal 2, issue.project_id assert_equal 2, issue.project_id
# Keep fixed_version # Keep fixed_version
...@@ -392,7 +392,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -392,7 +392,7 @@ class IssueTest < ActiveSupport::TestCase
target = Project.find(2) target = Project.find(2)
target.tracker_ids = [3] target.tracker_ids = [3]
target.save target.save
assert_equal false, issue.move_to(target) assert_equal false, issue.move_to_project(target)
issue.reload issue.reload
assert_equal 1, issue.project_id assert_equal 1, issue.project_id
end end
...@@ -401,7 +401,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -401,7 +401,7 @@ class IssueTest < ActiveSupport::TestCase
issue = Issue.find(1) issue = Issue.find(1)
copy = nil copy = nil
assert_difference 'Issue.count' do assert_difference 'Issue.count' do
copy = issue.move_to(issue.project, nil, :copy => true) copy = issue.move_to_project(issue.project, nil, :copy => true)
end end
assert_kind_of Issue, copy assert_kind_of Issue, copy
assert_equal issue.project, copy.project assert_equal issue.project, copy.project
...@@ -412,8 +412,9 @@ class IssueTest < ActiveSupport::TestCase ...@@ -412,8 +412,9 @@ class IssueTest < ActiveSupport::TestCase
issue = Issue.find(1) issue = Issue.find(1)
copy = nil copy = nil
assert_difference 'Issue.count' do assert_difference 'Issue.count' do
copy = issue.move_to(Project.find(3), Tracker.find(2), :copy => true) copy = issue.move_to_project(Project.find(3), Tracker.find(2), :copy => true)
end end
copy.reload
assert_kind_of Issue, copy assert_kind_of Issue, copy
assert_equal Project.find(3), copy.project assert_equal Project.find(3), copy.project
assert_equal Tracker.find(2), copy.tracker assert_equal Tracker.find(2), copy.tracker
...@@ -421,7 +422,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -421,7 +422,7 @@ class IssueTest < ActiveSupport::TestCase
assert_nil copy.custom_value_for(2) assert_nil copy.custom_value_for(2)
end end
context "#move_to" do context "#move_to_project" do
context "as a copy" do context "as a copy" do
setup do setup do
@issue = Issue.find(1) @issue = Issue.find(1)
...@@ -429,24 +430,24 @@ class IssueTest < ActiveSupport::TestCase ...@@ -429,24 +430,24 @@ class IssueTest < ActiveSupport::TestCase
end end
should "allow assigned_to changes" do should "allow assigned_to changes" do
@copy = @issue.move_to(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}}) @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:assigned_to_id => 3}})
assert_equal 3, @copy.assigned_to_id assert_equal 3, @copy.assigned_to_id
end end
should "allow status changes" do should "allow status changes" do
@copy = @issue.move_to(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:status_id => 2}}) @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:status_id => 2}})
assert_equal 2, @copy.status_id assert_equal 2, @copy.status_id
end end
should "allow start date changes" do should "allow start date changes" do
date = Date.today date = Date.today
@copy = @issue.move_to(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:start_date => date}}) @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:start_date => date}})
assert_equal date, @copy.start_date assert_equal date, @copy.start_date
end end
should "allow due date changes" do should "allow due date changes" do
date = Date.today date = Date.today
@copy = @issue.move_to(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:due_date => date}}) @copy = @issue.move_to_project(Project.find(3), Tracker.find(2), {:copy => true, :attributes => {:due_date => date}})
assert_equal date, @copy.due_date assert_equal date, @copy.due_date
end end
...@@ -457,7 +458,7 @@ class IssueTest < ActiveSupport::TestCase ...@@ -457,7 +458,7 @@ class IssueTest < ActiveSupport::TestCase
issue = Issue.find(12) issue = Issue.find(12)
assert issue.recipients.include?(issue.author.mail) assert issue.recipients.include?(issue.author.mail)
# move the issue to a private project # move the issue to a private project
copy = issue.move_to(Project.find(5), Tracker.find(2), :copy => true) copy = issue.move_to_project(Project.find(5), Tracker.find(2), :copy => true)
# author is not a member of project anymore # author is not a member of project anymore
assert !copy.recipients.include?(copy.author.mail) assert !copy.recipients.include?(copy.author.mail)
end end
......
...@@ -77,6 +77,13 @@ module Redmine ...@@ -77,6 +77,13 @@ module Redmine
@custom_field_values = nil @custom_field_values = nil
end end
def reset_custom_values!
@custom_field_values = nil
@custom_field_values_changed = true
values = custom_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
custom_values.each {|cv| cv.destroy unless custom_field_values.include?(cv)}
end
module ClassMethods module ClassMethods
end end
end end
......
...@@ -256,7 +256,7 @@ module CollectiveIdea #:nodoc: ...@@ -256,7 +256,7 @@ module CollectiveIdea #:nodoc:
end end
def leaf? def leaf?
right - left == 1 new_record? || (right - left == 1)
end end
# Returns true is this is a child node # Returns true is this is a child node
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment