Fixed: Relations are not displayed after adding/removing an issue relation (#7463).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4764 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
73a2d926f6
commit
898a8c885b
|
@ -28,6 +28,7 @@ class IssueRelationsController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
||||
format.js do
|
||||
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
|
||||
render :update do |page|
|
||||
page.replace_html "relations", :partial => 'issues/relations'
|
||||
if @relation.errors.empty?
|
||||
|
@ -47,7 +48,10 @@ class IssueRelationsController < ApplicationController
|
|||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
||||
format.js { render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'} }
|
||||
format.js {
|
||||
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
|
||||
render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -33,6 +33,19 @@ class IssueRelationsControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_new_xhr
|
||||
assert_difference 'IssueRelation.count' do
|
||||
@request.session[:user_id] = 3
|
||||
xhr :post, :new,
|
||||
:issue_id => 3,
|
||||
:relation => {:issue_to_id => '1', :relation_type => 'relates', :delay => ''}
|
||||
assert_select_rjs 'relations' do
|
||||
assert_select 'table', 1
|
||||
assert_select 'tr', 2 # relations
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_new_should_accept_id_with_hash
|
||||
assert_difference 'IssueRelation.count' do
|
||||
@request.session[:user_id] = 3
|
||||
|
@ -68,4 +81,20 @@ class IssueRelationsControllerTest < ActionController::TestCase
|
|||
post :destroy, :id => '2', :issue_id => '3'
|
||||
end
|
||||
end
|
||||
|
||||
def test_destroy_xhr
|
||||
IssueRelation.create!(:relation_type => IssueRelation::TYPE_RELATES) do |r|
|
||||
r.issue_from_id = 3
|
||||
r.issue_to_id = 1
|
||||
end
|
||||
|
||||
assert_difference 'IssueRelation.count', -1 do
|
||||
@request.session[:user_id] = 3
|
||||
xhr :post, :destroy, :id => '2', :issue_id => '3'
|
||||
assert_select_rjs 'relations' do
|
||||
assert_select 'table', 1
|
||||
assert_select 'tr', 1 # relation left
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue