Merged r3918 from trunk.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.0-stable@3968 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis 2010-08-19 04:31:30 +00:00
parent 9892ede7b7
commit 2f529fd834
6 changed files with 23 additions and 18 deletions

View File

@ -20,7 +20,7 @@ class IssuesController < ApplicationController
default_search_scope :issues default_search_scope :issues
before_filter :find_issue, :only => [:show, :edit, :update, :reply] before_filter :find_issue, :only => [:show, :edit, :update, :reply]
before_filter :find_issues, :only => [:bulk_edit, :move, :destroy] before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy]
before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete] before_filter :find_project, :only => [:new, :create, :update_form, :preview, :auto_complete]
before_filter :authorize, :except => [:index, :changes, :preview, :context_menu] before_filter :authorize, :except => [:index, :changes, :preview, :context_menu]
before_filter :find_optional_project, :only => [:index, :changes] before_filter :find_optional_project, :only => [:index, :changes]
@ -288,6 +288,11 @@ class IssuesController < ApplicationController
render :layout => false if request.xhr? render :layout => false if request.xhr?
end end
# TODO: more descriptive name? move to separate controller like IssueMovesController?
def perform_move
move
end
def destroy def destroy
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
if @hours > 0 if @hours > 0

View File

@ -6,7 +6,7 @@
<% end -%> <% end -%>
</ul> </ul>
<% form_tag({}, :id => 'move_form') do %> <% form_tag({:action => 'perform_move'}, :id => 'move_form') do %>
<%= @issues.collect {|i| hidden_field_tag('ids[]', i.id)}.join %> <%= @issues.collect {|i| hidden_field_tag('ids[]', i.id)}.join %>
<div class="box tabular"> <div class="box tabular">

View File

@ -124,7 +124,7 @@ ActionController::Routing::Routes.draw do |map|
issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show' issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show' issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
issues_actions.connect 'issues/:id/quoted', :action => 'reply', :id => /\d+/ issues_actions.connect 'issues/:id/quoted', :action => 'reply', :id => /\d+/
issues_actions.connect 'issues/:id/:action', :action => /edit|move|destroy/, :id => /\d+/ issues_actions.connect 'issues/:id/:action', :action => /edit|perform_move|destroy/, :id => /\d+/
issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/ issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/
end end
issues_routes.with_options :conditions => {:method => :put} do |issues_actions| issues_routes.with_options :conditions => {:method => :put} do |issues_actions|

View File

@ -69,7 +69,7 @@ Redmine::AccessControl.map do |map|
map.permission :add_issue_notes, {:issues => [:edit, :update, :reply]} map.permission :add_issue_notes, {:issues => [:edit, :update, :reply]}
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
map.permission :move_issues, {:issues => :move}, :require => :loggedin map.permission :move_issues, {:issues => [:move, :perform_move]}, :require => :loggedin
map.permission :delete_issues, {:issues => :destroy}, :require => :member map.permission :delete_issues, {:issues => :destroy}, :require => :member
# Queries # Queries
map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member

View File

@ -1038,22 +1038,22 @@ class IssuesControllerTest < ActionController::TestCase
assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier assert_redirected_to :controller => 'issues', :action => 'index', :project_id => Project.find(1).identifier
end end
def test_move_one_issue_to_another_project def test_perform_move_one_issue_to_another_project
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :move, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' post :perform_move, :id => 1, :new_project_id => 2, :tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 2, Issue.find(1).project_id assert_equal 2, Issue.find(1).project_id
end end
def test_move_one_issue_to_another_project_should_follow_when_needed def test_perform_move_one_issue_to_another_project_should_follow_when_needed
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :move, :id => 1, :new_project_id => 2, :follow => '1' post :perform_move, :id => 1, :new_project_id => 2, :follow => '1'
assert_redirected_to '/issues/1' assert_redirected_to '/issues/1'
end end
def test_bulk_move_to_another_project def test_bulk_perform_move_to_another_project
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :move, :ids => [1, 2], :new_project_id => 2 post :perform_move, :ids => [1, 2], :new_project_id => 2
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
# Issues moved to project 2 # Issues moved to project 2
assert_equal 2, Issue.find(1).project_id assert_equal 2, Issue.find(1).project_id
@ -1063,9 +1063,9 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal 2, Issue.find(2).tracker_id assert_equal 2, Issue.find(2).tracker_id
end end
def test_bulk_move_to_another_tracker def test_bulk_perform_move_to_another_tracker
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :move, :ids => [1, 2], :new_tracker_id => 2 post :perform_move, :ids => [1, 2], :new_tracker_id => 2
assert_redirected_to :action => 'index', :project_id => 'ecookbook' assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 2, Issue.find(1).tracker_id assert_equal 2, Issue.find(1).tracker_id
assert_equal 2, Issue.find(2).tracker_id assert_equal 2, Issue.find(2).tracker_id
@ -1075,19 +1075,19 @@ class IssuesControllerTest < ActionController::TestCase
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'Issue.count', 2 do assert_difference 'Issue.count', 2 do
assert_no_difference 'Project.find(1).issues.count' do assert_no_difference 'Project.find(1).issues.count' do
post :move, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'} post :perform_move, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}
end end
end end
assert_redirected_to 'projects/ecookbook/issues' assert_redirected_to 'projects/ecookbook/issues'
end end
context "#move via bulk copy" do context "#perform_move via bulk copy" do
should "allow not changing the issue's attributes" do should "allow not changing the issue's attributes" do
@request.session[:user_id] = 2 @request.session[:user_id] = 2
issue_before_move = Issue.find(1) issue_before_move = Issue.find(1)
assert_difference 'Issue.count', 1 do assert_difference 'Issue.count', 1 do
assert_no_difference 'Project.find(1).issues.count' do assert_no_difference 'Project.find(1).issues.count' do
post :move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => '' post :perform_move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => '', :status_id => '', :start_date => '', :due_date => ''
end end
end end
issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2}) issue_after_move = Issue.first(:order => 'id desc', :conditions => {:project_id => 2})
@ -1104,7 +1104,7 @@ class IssuesControllerTest < ActionController::TestCase
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'Issue.count', 2 do assert_difference 'Issue.count', 2 do
assert_no_difference 'Project.find(1).issues.count' do assert_no_difference 'Project.find(1).issues.count' do
post :move, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31' post :perform_move, :ids => [1, 2], :new_project_id => 2, :copy_options => {:copy => '1'}, :new_tracker_id => '', :assigned_to_id => 4, :status_id => 3, :start_date => '2009-12-01', :due_date => '2009-12-31'
end end
end end
@ -1122,7 +1122,7 @@ class IssuesControllerTest < ActionController::TestCase
def test_copy_to_another_project_should_follow_when_needed def test_copy_to_another_project_should_follow_when_needed
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1' post :perform_move, :ids => [1], :new_project_id => 2, :copy_options => {:copy => '1'}, :follow => '1'
issue = Issue.first(:order => 'id DESC') issue = Issue.first(:order => 'id DESC')
assert_redirected_to :controller => 'issues', :action => 'show', :id => issue assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
end end

View File

@ -86,7 +86,7 @@ class RoutingTest < ActionController::IntegrationTest
should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64' should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
should_route :get, "/issues/1/move", :controller => 'issues', :action => 'move', :id => '1' should_route :get, "/issues/1/move", :controller => 'issues', :action => 'move', :id => '1'
should_route :post, "/issues/1/move", :controller => 'issues', :action => 'move', :id => '1' should_route :post, "/issues/1/perform_move", :controller => 'issues', :action => 'perform_move', :id => '1'
should_route :post, "/issues/1/quoted", :controller => 'issues', :action => 'reply', :id => '1' should_route :post, "/issues/1/quoted", :controller => 'issues', :action => 'reply', :id => '1'