Feature #33868 » 0001-Make-adding-notes-to-closed-issues-configurable-per-.patch
| app/models/issue.rb | ||
|---|---|---|
|
# Returns true if user or current user is allowed to add notes to the issue
|
||
|
def notes_addable?(user=User.current)
|
||
|
return false unless tracker
|
||
|
# Adding notes on closed issues can be restricted per tracker settings
|
||
|
is_closed_without_transition = closed? && !closing? && !reopening?
|
||
|
return false if !tracker.notes_allowed_on_closed? && is_closed_without_transition
|
||
|
user_tracker_permission?(user, :add_issue_notes)
|
||
|
end
|
||
| app/models/tracker.rb | ||
|---|---|---|
|
'name',
|
||
|
'default_status_id',
|
||
|
'is_in_roadmap',
|
||
|
'notes_allowed_on_closed',
|
||
|
'core_fields',
|
||
|
'position',
|
||
|
'custom_field_ids',
|
||
| app/views/issues/_edit.html.erb | ||
|---|---|---|
|
<% end %>
|
||
|
</fieldset>
|
||
|
<% end %>
|
||
|
<% if @issue.notes_addable? %>
|
||
|
<fieldset id="add_notes"><legend><%= l(:field_notes) %></legend>
|
||
|
<fieldset id="add_notes" style="<%= @issue.notes_addable? ? '' : 'display:none;' %>"><legend><%= l(:field_notes) %></legend>
|
||
|
<%= f.textarea :notes, :cols => 60, :rows => 10, :class => 'wiki-edit',
|
||
|
:data => {
|
||
|
:auto_complete => true
|
||
| ... | ... | |
|
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
|
||
|
</fieldset>
|
||
|
<% end %>
|
||
|
<% if !@issue.attributes_editable? && User.current.allowed_to?(:add_issue_watchers, @issue.project) %>
|
||
|
<%= update_data_sources_for_auto_complete({users: watchers_autocomplete_for_mention_path(project_id: @issue.project, q: '', object_type: 'issue',
|
||
|
object_id: @issue.id)}) %>
|
||
| app/views/trackers/_form.html.erb | ||
|---|---|---|
|
:required => true %>
|
||
|
</p>
|
||
|
<p><%= f.check_box :is_in_roadmap %></p>
|
||
|
<p><%= f.check_box :notes_allowed_on_closed %></p>
|
||
|
<p><%= f.textarea :description, :rows => 4 %></p>
|
||
|
<p>
|
||
|
<label><%= l(:field_core_fields) %></label>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
field_last_activity_date: Last activity
|
||
|
field_thousands_delimiter: Thousands delimiter
|
||
|
field_ratio_interval: Ratio interval
|
||
|
field_notes_allowed_on_closed: Allow notes on closed issues
|
||
|
setting_app_title: Application title
|
||
|
setting_welcome_text: Welcome text
|
||
| db/migrate/20260201094039_add_notes_allowed_on_closed_to_trackers.rb | ||
|---|---|---|
|
class AddNotesAllowedOnClosedToTrackers < ActiveRecord::Migration[6.1]
|
||
|
def change
|
||
|
add_column :trackers, :notes_allowed_on_closed, :boolean, default: true, null: false
|
||
|
end
|
||
|
end
|
||
| test/unit/issue_test.rb | ||
|---|---|---|
|
assert_equal '', issue.notes
|
||
|
end
|
||
|
def test_should_not_allow_notes_on_closed_issue_when_tracker_disallows
|
||
|
tracker = Tracker.find(1)
|
||
|
tracker.update!(notes_allowed_on_closed: false)
|
||
|
issue = Issue.find(8)
|
||
|
user = User.find(2)
|
||
|
issue.init_journal(user)
|
||
|
issue.send :safe_attributes=, {'notes' => 'note'}, user
|
||
|
assert_equal '', issue.notes
|
||
|
end
|
||
|
def test_should_allow_notes_on_closed_issue_when_reopening
|
||
|
tracker = Tracker.find(1)
|
||
|
tracker.update!(notes_allowed_on_closed: false)
|
||
|
issue = Issue.find(8)
|
||
|
issue.status_id = 1
|
||
|
user = User.find(2)
|
||
|
issue.init_journal(user)
|
||
|
issue.send :safe_attributes=, {'notes' => 'note'}, user
|
||
|
assert_equal 'note', issue.notes
|
||
|
end
|
||
|
def test_safe_attributes_should_accept_target_tracker_enabled_fields
|
||
|
source = Tracker.find(1)
|
||
|
source.core_fields = []
|
||
| test/unit/mail_handler_test.rb | ||
|---|---|---|
|
assert !journal.notes.match(/^Start Date:/i)
|
||
|
end
|
||
|
def test_update_issue_should_not_allow_notes_on_closed_issue_when_tracker_disallows
|
||
|
issue = Issue.find(2)
|
||
|
issue.update!(status: IssueStatus.find_by(:is_closed => true))
|
||
|
issue.tracker.update!(notes_allowed_on_closed: false)
|
||
|
assert_no_difference 'Journal.count' do
|
||
|
submit_email('ticket_reply.eml')
|
||
|
end
|
||
|
end
|
||
|
def test_update_issue_with_attachment
|
||
|
assert_difference 'Journal.count' do
|
||
|
assert_difference 'JournalDetail.count' do
|
||
- « Previous
- 1
- 2
- 3
- 4
- Next »