mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-20 01:56:06 +10:00
Merge branch 'milestone-change-note' into 'master'
Create a note when issue milestone was changed Part of #1207
This commit is contained in:
@@ -90,6 +90,22 @@ class Note < ActiveRecord::Base
|
||||
create(note_options, without_protection: true)
|
||||
end
|
||||
|
||||
def create_milestone_change_note(noteable, project, author, milestone)
|
||||
body = if milestone.nil?
|
||||
'_Milestone removed_'
|
||||
else
|
||||
"_Milestone changed to #{milestone.title}_"
|
||||
end
|
||||
|
||||
create({
|
||||
noteable: noteable,
|
||||
project: project,
|
||||
author: author,
|
||||
note: body,
|
||||
system: true
|
||||
}, without_protection: true)
|
||||
end
|
||||
|
||||
def create_assignee_change_note(noteable, project, author, assignee)
|
||||
body = assignee.nil? ? '_Assignee removed_' : "_Reassigned to @#{assignee.username}_"
|
||||
|
||||
|
||||
@@ -10,5 +10,9 @@ module Issues
|
||||
def execute_hooks(issue)
|
||||
issue.project.execute_hooks(issue.to_hook_data, :issue_hooks)
|
||||
end
|
||||
|
||||
def create_milestone_note(issue)
|
||||
Note.create_milestone_change_note(issue, issue.project, current_user, issue.milestone)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,6 +13,10 @@ module Issues
|
||||
if params.present? && issue.update_attributes(params)
|
||||
issue.reset_events_cache
|
||||
|
||||
if issue.previous_changes.include?('milestone_id')
|
||||
create_milestone_note(issue)
|
||||
end
|
||||
|
||||
if issue.previous_changes.include?('assignee_id')
|
||||
notification_service.reassigned_issue(issue, current_user)
|
||||
create_assignee_note(issue)
|
||||
|
||||
@@ -16,5 +16,9 @@ module MergeRequests
|
||||
merge_request.project.execute_hooks(merge_request.to_hook_data, :merge_request_hooks)
|
||||
end
|
||||
end
|
||||
|
||||
def create_milestone_note(merge_request)
|
||||
Note.create_milestone_change_note(merge_request, merge_request.project, current_user, merge_request.milestone)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,6 +22,10 @@ module MergeRequests
|
||||
if params.present? && merge_request.update_attributes(params)
|
||||
merge_request.reset_events_cache
|
||||
|
||||
if merge_request.previous_changes.include?('milestone_id')
|
||||
create_milestone_note(merge_request)
|
||||
end
|
||||
|
||||
if merge_request.previous_changes.include?('assignee_id')
|
||||
notification_service.reassigned_merge_request(merge_request, current_user)
|
||||
create_assignee_note(merge_request)
|
||||
|
||||
@@ -254,7 +254,7 @@ class NotificationService
|
||||
# Remove users with disabled notifications from array
|
||||
# Also remove duplications and nil recipients
|
||||
def reject_muted_users(users, project = nil)
|
||||
users = users.compact.uniq
|
||||
users = users.to_a.compact.uniq
|
||||
|
||||
users.reject do |user|
|
||||
next user.notification.disabled? unless project
|
||||
|
||||
@@ -248,7 +248,7 @@ describe "Issues", feature: true do
|
||||
find('.edit-issue.inline-update').select(milestone.title, from: 'issue_milestone_id')
|
||||
click_button 'Update Issue'
|
||||
|
||||
page.should have_content "Milestone"
|
||||
page.should have_content "Milestone changed to #{milestone.title}"
|
||||
page.has_select?('issue_assignee_id', :selected => milestone.title)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user