Fixed that relations may not be refreshed when adding a follows relation (#13251).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11461 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2013-02-24 09:59:45 +00:00
parent 85b872f340
commit 8e17c2aeac
3 changed files with 13 additions and 1 deletions

View File

@ -50,7 +50,7 @@ class IssueRelationsController < ApplicationController
respond_to do |format|
format.html { redirect_to issue_path(@issue) }
format.js {
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
@relations = @issue.reload.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
}
format.api {
if saved

View File

@ -187,6 +187,7 @@ class Issue < ActiveRecord::Base
def reload(*args)
@workflow_rule_by_attribute = nil
@assignable_versions = nil
@relations = nil
super
end

View File

@ -87,6 +87,17 @@ class IssueRelationsControllerTest < ActionController::TestCase
end
end
def test_create_follows_relation_should_update_relations_list
issue1 = Issue.generate!(:subject => 'Followed issue', :start_date => Date.yesterday, :due_date => Date.today)
issue2 = Issue.generate!
assert_difference 'IssueRelation.count' do
xhr :post, :create, :issue_id => issue2.id,
:relation => {:issue_to_id => issue1.id, :relation_type => 'follows', :delay => ''}
end
assert_match /Followed issue/, response.body
end
def test_should_create_relations_with_visible_issues_only
Setting.cross_project_issue_relations = '1'
assert_nil Issue.visible(User.find(3)).find_by_id(4)