Fix issue closed permission bug

This commit is contained in:
Alexander Meindl 2019-04-27 16:58:07 +02:00
parent 3644faabe0
commit 01a3fe9afe
3 changed files with 22 additions and 4 deletions

View File

@ -5,7 +5,7 @@ Changelog
++++++
- fix mail notification if issue author changed
- fix permission bug for closed issues with freezed mode
2.0.20
++++++

View File

@ -145,10 +145,9 @@ module Additionals
end
def validate_change_on_closed
return true if !closed? ||
new_record? ||
!Additionals.setting?(:issue_freezed_with_close) ||
return true if new_record? ||
!status_was.is_closed ||
!Additionals.setting?(:issue_freezed_with_close) ||
User.current.allowed_to?(:edit_closed_issues, project)
errors.add :base, :issue_changes_not_allowed

View File

@ -65,6 +65,25 @@ class IssueTest < Additionals::TestCase
assert_not issue.save
issue.reload
assert_not_equal 'Should be not be saved', issue.subject
issue.status_id = 1
assert issue.status_was.is_closed
assert_not issue.closed?
assert_not issue.save
end
end
def test_new_issue_should_always_be_changeable
with_additionals_settings(issue_freezed_with_close: 1) do
User.current = users(:users_003)
issue = Issue.generate subject: 'new issue for closing test',
status_id: 1
assert issue.save
issue = Issue.generate subject: 'new issue for closing test and closed state',
status_id: 5
assert issue.save
end
end