From e9370c3fce054c8016d2cc18988d78f8aae4b19f 2016-08-31 16:54:24 From: Jean-Philippe Lang Date: 2016-08-31 16:54:24 Subject: [PATCH] Merged r15740 and r15748 (#23410). git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@15768 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index b842023..c640aad 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -489,6 +489,9 @@ class IssuesController < ApplicationController render_error l(:error_no_default_issue_status) return false end + elsif request.get? + 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 7c07adb..a6501c3 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 bf96702..50fe2b9 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 83cdb27..deed445 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -1900,6 +1900,24 @@ class IssuesControllerTest < ActionController::TestCase 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