Commit 3c70b919 authored by jplang's avatar jplang

Fixed that watchers list is not updated when changing project on the new issue form (#17762).

git-svn-id: https://svn.redmine.org/redmine/trunk@16511 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent d5483f26
......@@ -375,6 +375,9 @@ class Issue < ActiveRecord::Base
def project=(project, keep_tracker=false)
project_was = self.project
association(:project).writer(project)
if project != project_was
@safe_attribute_names = nil
end
if project_was && project && project_was != project
@assignable_versions = nil
......
<% if @issue.safe_attribute? 'watcher_user_ids' -%>
<p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
<span id="watchers_inputs">
<%= watchers_checkboxes(@issue, users_for_new_issue_watchers(@issue)) %>
</span>
<span class="search_for_watchers">
<%= link_to l(:label_search_for_watchers),
{:controller => 'watchers', :action => 'new', :project_id => @issue.project},
:class => 'icon icon-add-bullet',
:remote => true,
:method => 'get' %>
</span>
</p>
<% end %>
......@@ -32,20 +32,9 @@
<p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
<% if @issue.safe_attribute? 'watcher_user_ids' -%>
<p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
<span id="watchers_inputs">
<%= watchers_checkboxes(@issue, users_for_new_issue_watchers(@issue)) %>
</span>
<span class="search_for_watchers">
<%= link_to l(:label_search_for_watchers),
{:controller => 'watchers', :action => 'new', :project_id => @issue.project},
:class => 'icon icon-add-bullet',
:remote => true,
:method => 'get' %>
</span>
</p>
<% end %>
<div id="watchers_form_container">
<%= render :partial => 'issues/watchers_form' %>
</div>
</div>
<%= submit_tag l(:button_create) %>
......
replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
<% if params[:form_update_triggered_by] == "issue_project_id" %>
$("#watchers_form_container").html('<%= escape_javascript(render :partial => 'issues/watchers_form') %>');
<% end %>
......@@ -803,6 +803,16 @@ class IssueTest < ActiveSupport::TestCase
assert_equal 1, issue.status_id
end
def test_safe_attributes_names_should_be_updated_when_changing_project
issue = Issue.new
with_current_user(User.find(2)) do
assert_not_include 'watcher_user_ids', issue.safe_attribute_names
issue.project_id = 1
assert_include 'watcher_user_ids', issue.safe_attribute_names
end
end
def test_safe_attributes_names_should_not_include_disabled_field
tracker = Tracker.new(:core_fields => %w(assigned_to_id fixed_version_id))
......
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