]> source.dussan.org Git - redmine.git/commitdiff
Fixed: Relations are not displayed after adding/removing an issue relation (#7463).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 27 Jan 2011 21:38:47 +0000 (21:38 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 27 Jan 2011 21:38:47 +0000 (21:38 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4764 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issue_relations_controller.rb
test/functional/issue_relations_controller_test.rb

index 7462adca88dbc8d3a3e6b33864b1a067da2afcb4..b095df37a5114b9d8dd7aa1ef56b401645d7f1ba 100644 (file)
@@ -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
   
index 6c50b707f72a172c9519eae5bdff07fa0ac8621a..ff3bb8d0d8f13184e4b5fc02c9befdb50b8a2199 100644 (file)
@@ -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