mirror of
https://github.com/redmine/redmine.git
synced 2025-12-16 05:20:28 +01:00
Fix that Issues API bypasses add_issue_notes permission (#33689).
Patch by Junya Tomono and Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@19975 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -5901,6 +5901,24 @@ class IssuesControllerTest < Redmine::ControllerTest
|
||||
assert_equal spent_hours_before + 2.5, issue.spent_hours
|
||||
end
|
||||
|
||||
def test_put_update_should_check_add_issue_notes_permission
|
||||
role = Role.find(1)
|
||||
role.remove_permission! :add_issue_notes
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_no_difference 'Journal.count' do
|
||||
put(
|
||||
:update,
|
||||
:params => {
|
||||
:id => 1,
|
||||
:issue => {
|
||||
:notes => 'New note'
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def test_put_update_should_preserve_parent_issue_even_if_not_visible
|
||||
parent = Issue.generate!(:project_id => 1, :is_private => true)
|
||||
issue = Issue.generate!(:parent_issue_id => parent.id)
|
||||
|
||||
@@ -898,6 +898,23 @@ class IssueTest < ActiveSupport::TestCase
|
||||
assert_equal Date.parse('2012-07-14'), issue.due_date
|
||||
end
|
||||
|
||||
def test_safe_attributes_notes_should_check_add_issue_notes_permission
|
||||
# With add_issue_notes permission
|
||||
user = User.find(2)
|
||||
issue = Issue.new(:project => Project.find(1))
|
||||
issue.init_journal(user)
|
||||
issue.send :safe_attributes=, {'notes' => 'note'}, user
|
||||
assert_equal 'note', issue.notes
|
||||
|
||||
# Without add_issue_notes permission
|
||||
Role.find(1).remove_permission!(:add_issue_notes)
|
||||
issue = Issue.new(:project => Project.find(1))
|
||||
user.reload
|
||||
issue.init_journal(user)
|
||||
issue.send :safe_attributes=, {'notes' => 'note'}, user
|
||||
assert_equal '', issue.notes
|
||||
end
|
||||
|
||||
def test_safe_attributes_should_accept_target_tracker_enabled_fields
|
||||
source = Tracker.find(1)
|
||||
source.core_fields = []
|
||||
|
||||
Reference in New Issue
Block a user