@@ -28,6 +28,7 class IssueRelationsController < ApplicationController | |||||
28 | respond_to do |format| |
|
28 | respond_to do |format| | |
29 | format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } |
|
29 | format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } | |
30 | format.js do |
|
30 | format.js do | |
|
31 | @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } | |||
31 | render :update do |page| |
|
32 | render :update do |page| | |
32 | page.replace_html "relations", :partial => 'issues/relations' |
|
33 | page.replace_html "relations", :partial => 'issues/relations' | |
33 | if @relation.errors.empty? |
|
34 | if @relation.errors.empty? | |
@@ -47,7 +48,10 class IssueRelationsController < ApplicationController | |||||
47 | end |
|
48 | end | |
48 | respond_to do |format| |
|
49 | respond_to do |format| | |
49 | format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } |
|
50 | format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } | |
50 | format.js { render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'} } |
|
51 | format.js { | |
|
52 | @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } | |||
|
53 | render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'} | |||
|
54 | } | |||
51 | end |
|
55 | end | |
52 | end |
|
56 | end | |
53 |
|
57 |
@@ -33,6 +33,19 class IssueRelationsControllerTest < ActionController::TestCase | |||||
33 | end |
|
33 | end | |
34 | end |
|
34 | end | |
35 |
|
35 | |||
|
36 | def test_new_xhr | |||
|
37 | assert_difference 'IssueRelation.count' do | |||
|
38 | @request.session[:user_id] = 3 | |||
|
39 | xhr :post, :new, | |||
|
40 | :issue_id => 3, | |||
|
41 | :relation => {:issue_to_id => '1', :relation_type => 'relates', :delay => ''} | |||
|
42 | assert_select_rjs 'relations' do | |||
|
43 | assert_select 'table', 1 | |||
|
44 | assert_select 'tr', 2 # relations | |||
|
45 | end | |||
|
46 | end | |||
|
47 | end | |||
|
48 | ||||
36 | def test_new_should_accept_id_with_hash |
|
49 | def test_new_should_accept_id_with_hash | |
37 | assert_difference 'IssueRelation.count' do |
|
50 | assert_difference 'IssueRelation.count' do | |
38 | @request.session[:user_id] = 3 |
|
51 | @request.session[:user_id] = 3 | |
@@ -68,4 +81,20 class IssueRelationsControllerTest < ActionController::TestCase | |||||
68 | post :destroy, :id => '2', :issue_id => '3' |
|
81 | post :destroy, :id => '2', :issue_id => '3' | |
69 | end |
|
82 | end | |
70 | end |
|
83 | end | |
|
84 | ||||
|
85 | def test_destroy_xhr | |||
|
86 | IssueRelation.create!(:relation_type => IssueRelation::TYPE_RELATES) do |r| | |||
|
87 | r.issue_from_id = 3 | |||
|
88 | r.issue_to_id = 1 | |||
|
89 | end | |||
|
90 | ||||
|
91 | assert_difference 'IssueRelation.count', -1 do | |||
|
92 | @request.session[:user_id] = 3 | |||
|
93 | xhr :post, :destroy, :id => '2', :issue_id => '3' | |||
|
94 | assert_select_rjs 'relations' do | |||
|
95 | assert_select 'table', 1 | |||
|
96 | assert_select 'tr', 1 # relation left | |||
|
97 | end | |||
|
98 | end | |||
|
99 | end | |||
71 | end |
|
100 | end |
General Comments 0
You need to be logged in to leave comments.
Login now