From 88d5663ad261a863db7c6985aa3fd22e74b62684 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 1 Dec 2012 17:57:30 +0000 Subject: [PATCH] Code cleanup. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10903 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 9 +++------ test/functional/projects_controller_test.rb | 6 ++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 628b1a12c..dc646eb32 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -116,11 +116,7 @@ class ProjectsController < ApplicationController @source_project = Project.find(params[:id]) if request.get? @project = Project.copy_from(@source_project) - if @project - @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? - else - redirect_to :controller => 'admin', :action => 'projects' - end + @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? else Mailer.with_deliveries(params[:notifications] == '1') do @project = Project.new @@ -139,7 +135,8 @@ class ProjectsController < ApplicationController end end rescue ActiveRecord::RecordNotFound - redirect_to :controller => 'admin', :action => 'projects' + # source_project not found + render_404 end # Show @project diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 49bd69291..b606f4802 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -523,6 +523,12 @@ class ProjectsControllerTest < ActionController::TestCase :attributes => {:name => 'project[enabled_module_names][]', :value => 'issue_tracking'} end + def test_get_copy_with_invalid_source_should_respond_with_404 + @request.session[:user_id] = 1 + get :copy, :id => 99 + assert_response 404 + end + def test_post_copy_should_copy_requested_items @request.session[:user_id] = 1 # admin CustomField.delete_all