summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-08-20 11:26:43 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-08-20 11:26:43 +0000
commit011606745fc7e2d06733d650be680c28c488974d (patch)
treed9988fbe5ef6b1816674951d1afbf40b6614c12d
parent1fad99ebe3880952c2fbade9b6ae44d57f8f4857 (diff)
downloadredmine-011606745fc7e2d06733d650be680c28c488974d.tar.gz
redmine-011606745fc7e2d06733d650be680c28c488974d.zip
New issue raises an error if no projects available (#23410).
git-svn-id: http://svn.redmine.org/redmine/trunk@15740 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/issues_controller.rb11
-rw-r--r--config/locales/en.yml1
-rw-r--r--config/locales/fr.yml1
-rw-r--r--test/functional/issues_controller_test.rb20
4 files changed, 25 insertions, 8 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 05fb064cd..686a6b47f 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -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
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 7c07adbe6..a6501c38a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -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:'
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index bf9670212..50fe2b923 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -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 :'
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 142ccc356..e4c6cd234 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -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