summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2021-04-22 03:07:42 +0000
committerGo MAEDA <maeda@farend.jp>2021-04-22 03:07:42 +0000
commitccd00df71ca30e8f10c8642b7a16763a6e19f6f2 (patch)
tree1c8407f113f2c15be0a86f1ca3348ce59bc66e4b
parentb719565c411fecad195cf966eb79520bd7884269 (diff)
downloadredmine-ccd00df71ca30e8f10c8642b7a16763a6e19f6f2.tar.gz
redmine-ccd00df71ca30e8f10c8642b7a16763a6e19f6f2.zip
MailHandler raises NameError exception when generating error message (#35100).
Patch by Dmitry Makurin and Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@20959 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/mail_handler.rb4
-rw-r--r--test/unit/mail_handler_test.rb17
2 files changed, 19 insertions, 2 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 0fd7f10af..102cd8b75 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -227,7 +227,7 @@ class MailHandler < ActionMailer::Base
unless handler_options[:no_permission_check]
unless user.allowed_to?(:add_issue_notes, issue.project) ||
user.allowed_to?(:edit_issues, issue.project)
- raise UnauthorizedAction, "not allowed to add notes on issues to project [#{project.name}]"
+ raise UnauthorizedAction, "not allowed to add notes on issues to project [#{issue.project.name}]"
end
end
@@ -276,7 +276,7 @@ class MailHandler < ActionMailer::Base
end
unless handler_options[:no_permission_check]
- raise UnauthorizedAction, "not allowed to add messages to project [#{project.name}]" unless user.allowed_to?(:add_messages, message.project)
+ raise UnauthorizedAction, "not allowed to add messages to project [#{message.project.name}]" unless user.allowed_to?(:add_messages, message.project)
end
if !message.locked?
diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb
index 95baa3de1..836df11d6 100644
--- a/test/unit/mail_handler_test.rb
+++ b/test/unit/mail_handler_test.rb
@@ -1051,6 +1051,16 @@ class MailHandlerTest < ActiveSupport::TestCase
end
end
+ def test_reply_to_a_issue_without_permission
+ set_tmp_attachments_directory
+ Role.all.each {|r| r.remove_permission! :add_issue_notes, :edit_issues}
+ assert_no_difference 'Issue.count' do
+ assert_no_difference 'Journal.count' do
+ assert_not submit_email('ticket_reply_with_status.eml')
+ end
+ end
+ end
+
def test_reply_to_a_nonexitent_journal
journal_id = Issue.find(2).journals.last.id
Journal.destroy(journal_id)
@@ -1102,6 +1112,13 @@ class MailHandlerTest < ActiveSupport::TestCase
end
end
+ def test_reply_to_a_topic_without_permission
+ Role.all.each {|r| r.remove_permission! :add_messages}
+ assert_no_difference('Message.count') do
+ assert_not submit_email('message_reply_by_subject.eml')
+ end
+ end
+
def test_should_convert_tags_of_html_only_emails
with_settings :text_formatting => 'textile' do
issue = submit_email('ticket_html_only.eml', :issue => {:project => 'ecookbook'})