Index: test/functional/search_controller_test.rb =================================================================== --- test/functional/search_controller_test.rb (revision 1212) +++ test/functional/search_controller_test.rb (working copy) @@ -78,6 +78,11 @@ assert_equal 2, results.size end + def test_search_with_invalid_project_id + get :index, :id => 195, :q => 'recipe' + assert_response 404 + assert_nil assigns(:results) + end def test_quick_jump_to_issue # issue of a public project get :index, :q => "3" Index: app/controllers/application.rb =================================================================== --- app/controllers/application.rb (revision 1212) +++ app/controllers/application.rb (working copy) @@ -102,13 +102,14 @@ # make sure that the user is a member of the project (or admin) if project is private # used as a before_filter for actions that do not require any particular permission on the project def check_project_privacy - unless @project.active? + if @project && @project.active? + return true if @project.is_public? || User.current.member_of?(@project) || User.current.admin? + User.current.logged? ? render_403 : require_login + else @project = nil render_404 return false end - return true if @project.is_public? || User.current.member_of?(@project) || User.current.admin? - User.current.logged? ? render_403 : require_login end # store current uri in session. Index: app/controllers/search_controller.rb =================================================================== --- app/controllers/search_controller.rb (revision 1212) +++ app/controllers/search_controller.rb (working copy) @@ -107,6 +107,5 @@ def find_project @project = Project.find(params[:id]) rescue ActiveRecord::RecordNotFound - render_404 end end