Removes RJS from RepositoriesController.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10048 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-07-19 17:27:14 +00:00
parent 38060a2cf0
commit 87da04c808
4 changed files with 20 additions and 31 deletions

View File

@ -236,22 +236,6 @@ class RepositoriesController < ApplicationController
if @issue if @issue
@changeset.issues << @issue @changeset.issues << @issue
respond_to do |format|
format.js {
render :update do |page|
page.replace_html "related-issues", :partial => "related_issues"
page.visual_effect :highlight, "related-issue-#{@issue.id}"
end
}
end
else
respond_to do |format|
format.js {
render :update do |page|
page.alert(l(:label_issue) + ' ' + l('activerecord.errors.messages.invalid'))
end
}
end
end end
end end
@ -262,14 +246,6 @@ class RepositoriesController < ApplicationController
if @issue if @issue
@changeset.issues.delete(@issue) @changeset.issues.delete(@issue)
end end
respond_to do |format|
format.js {
render :update do |page|
page.remove "related-issue-#{@issue.id}"
end if @issue
}
end
end end
def diff def diff
@ -456,4 +432,3 @@ class RepositoriesController < ApplicationController
graph.burn graph.burn
end end
end end

View File

@ -0,0 +1,6 @@
<% if @issue %>
Element.update('related-issues', '<%= escape_javascript(render :partial => "related_issues") %>');
Effect.highlight('related-issue-<%= @issue.id %>');
<% else %>
alert("<%= escape_javascript(l(:label_issue) + ' ' + l('activerecord.errors.messages.invalid')) %>");
<% end %>

View File

@ -0,0 +1 @@
Element.remove('related-issue-<%= @issue.id %>');

View File

@ -171,20 +171,25 @@ class RepositoriesControllerTest < ActionController::TestCase
def test_add_related_issue def test_add_related_issue
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'Changeset.find(103).issues.size' do assert_difference 'Changeset.find(103).issues.size' do
post :add_related_issue, :id => 1, :rev => 4, :issue_id => 2, :format => 'js' xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => 2, :format => 'js'
assert_response :success assert_response :success
assert_template 'add_related_issue'
assert_equal 'text/javascript', response.content_type
end end
assert_select_rjs :replace_html, 'related-issues'
assert_equal [2], Changeset.find(103).issue_ids assert_equal [2], Changeset.find(103).issue_ids
assert_include 'related-issues', response.body
assert_include 'Feature request #2', response.body
end end
def test_add_related_issue_with_invalid_issue_id def test_add_related_issue_with_invalid_issue_id
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_no_difference 'Changeset.find(103).issues.size' do assert_no_difference 'Changeset.find(103).issues.size' do
post :add_related_issue, :id => 1, :rev => 4, :issue_id => 9999, :format => 'js' xhr :post, :add_related_issue, :id => 1, :rev => 4, :issue_id => 9999, :format => 'js'
assert_response :success assert_response :success
assert_template 'add_related_issue'
assert_equal 'text/javascript', response.content_type
end end
assert_include 'alert("Issue is invalid")', @response.body assert_include 'alert("Issue is invalid")', response.body
end end
def test_remove_related_issue def test_remove_related_issue
@ -193,11 +198,13 @@ class RepositoriesControllerTest < ActionController::TestCase
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'Changeset.find(103).issues.size', -1 do assert_difference 'Changeset.find(103).issues.size', -1 do
delete :remove_related_issue, :id => 1, :rev => 4, :issue_id => 2, :format => 'js' xhr :delete, :remove_related_issue, :id => 1, :rev => 4, :issue_id => 2, :format => 'js'
assert_response :success assert_response :success
assert_template 'remove_related_issue'
assert_equal 'text/javascript', response.content_type
end end
assert_select_rjs :remove, 'related-issue-2'
assert_equal [1], Changeset.find(103).issue_ids assert_equal [1], Changeset.find(103).issue_ids
assert_include 'related-issue-2', response.body
end end
def test_graph_commits_per_month def test_graph_commits_per_month