Project

General

Profile

Patch #22345 » 0001-Do-not-propose-trackers-which-disallow-parent_issue_.patch

Jens Krämer, 2016-03-30 08:11

View differences:

app/helpers/issues_helper.rb
162 162
  # Returns a link for adding a new subtask to the given issue
163 163
  def link_to_new_subtask(issue)
164 164
    attrs = {
165
      :tracker_id => issue.tracker,
166 165
      :parent_issue_id => issue
167 166
    }
167
    attrs[:tracker_id] = issue.tracker unless issue.tracker.disabled_core_fields.include?('parent_issue_id')
168 168
    link_to(l(:button_add), new_project_issue_path(issue.project, :issue => attrs))
169 169
  end
170 170

  
app/views/issues/_form.html.erb
14 14
<% end %>
15 15

  
16 16
<% if @issue.safe_attribute? 'tracker_id' %>
17
<p><%= f.select :tracker_id, @issue.project.trackers.collect {|t| [t.name, t.id]}, {:required => true},
17
<p><%= f.select :tracker_id, @issue.project.trackers.reject { |t| @issue.new_record? && @issue.parent_issue_id.present? && @issue.tracker_id != t.id && t.disabled_core_fields.include?('parent_issue_id') }.collect {|t| [t.name, t.id]}, {:required => true},
18 18
                :onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)" %></p>
19 19
<% end %>
20 20

  
test/functional/issues_controller_test.rb
1988 1988
    assert_response 404
1989 1989
  end
1990 1990

  
1991
  def test_new_with_parent_id_should_only_propose_valid_trackers
1992
    @request.session[:user_id] = 2
1993
    t = Tracker.find(3)
1994
    assert !t.disabled_core_fields.include?('parent_issue_id')
1995

  
1996
    get :new, :project_id => 1, issue: { parent_issue_id: 1 }
1997
    assert_response :success
1998
    assert_select 'option', text: /#{t.name}/, count: 1
1999

  
2000
    t.core_fields = Tracker::CORE_FIELDS - ['parent_issue_id']
2001
    t.save!
2002
    assert t.disabled_core_fields.include?('parent_issue_id')
2003
    get :new, :project_id => 1, issue: { parent_issue_id: 1 }
2004
    assert_response :success
2005
    assert_select 'option', text: /#{t.name}/, count: 0
2006
  end
2007

  
1991 2008
  def test_update_form_for_new_issue
1992 2009
    @request.session[:user_id] = 2
1993 2010
    xhr :post, :new, :project_id => 1,
(1-1/2)