Commit c4519bb8 authored by jplang's avatar jplang

New issue raises an error if no projects available (#23410).

git-svn-id: https://svn.redmine.org/redmine/trunk@15740 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent ea1a1e2d
......@@ -151,13 +151,7 @@ class IssuesController < ApplicationController
return
else
respond_to do |format|
format.html {
if @issue.project.nil?
render_error :status => 422
else
render :action => 'new'
end
}
format.html { render :action => 'new' }
format.api { render_validation_errors(@issue) }
end
end
......@@ -490,6 +484,9 @@ class IssuesController < ApplicationController
render_error l(:error_no_default_issue_status)
return false
end
else
render_error :message => l(:error_no_projects_with_tracker_allowed_for_new_issue), :status => 403
return false
end
@priorities = IssuePriority.active
......
......@@ -214,6 +214,7 @@ en:
error_attachment_extension_not_allowed: "Attachment extension %{extension} is not allowed"
error_ldap_bind_credentials: "Invalid LDAP Account/Password"
error_no_tracker_allowed_for_new_issue_in_project: "The project doesn't have any trackers for which you can create an issue"
error_no_projects_with_tracker_allowed_for_new_issue: "There are no projects with trackers for which you can create an issue"
mail_subject_lost_password: "Your %{value} password"
mail_body_lost_password: 'To change your password, click on the following link:'
......
......@@ -234,6 +234,7 @@ fr:
error_attachment_extension_not_allowed: "L'extension %{extension} n'est pas autorisée"
error_ldap_bind_credentials: "Identifiant ou mot de passe LDAP incorrect"
error_no_tracker_allowed_for_new_issue_in_project: "Le projet ne dispose d'aucun tracker sur lequel vous pouvez créer une demande"
error_no_projects_with_tracker_allowed_for_new_issue: "Aucun projet ne dispose d'un tracker sur lequel vous pouvez créer une demande"
mail_subject_lost_password: "Votre mot de passe %{value}"
mail_body_lost_password: 'Pour changer votre mot de passe, cliquez sur le lien suivant :'
......
......@@ -1817,6 +1817,24 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_response 403
end
def test_new_without_projects_should_respond_with_403
Project.delete_all
@request.session[:user_id] = 2
get :new
assert_response 403
assert_select_error /no projects/
end
def test_new_without_enabled_trackers_on_projects_should_respond_with_403
Project.all.each {|p| p.trackers.clear }
@request.session[:user_id] = 2
get :new
assert_response 403
assert_select_error /no projects/
end
def test_new_should_preselect_default_version
version = Version.generate!(:project_id => 1)
Project.find(1).update_attribute :default_version_id, version.id
......@@ -2540,7 +2558,7 @@ class IssuesControllerTest < Redmine::ControllerTest
:issue => {:project_id => 3,
:tracker_id => 2,
:subject => 'Foo'}
assert_response 422
assert_response 403
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment