Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
c4c877e4
Commit
c4c877e4
authored
Jun 10, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'milestone-change-note' into 'master'
Create a note when issue milestone was changed Part of #1207
parents
d2052925
f2353352
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
2 deletions
+34
-2
app/models/note.rb
app/models/note.rb
+16
-0
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+4
-0
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+4
-0
app/services/merge_requests/base_service.rb
app/services/merge_requests/base_service.rb
+4
-0
app/services/merge_requests/update_service.rb
app/services/merge_requests/update_service.rb
+4
-0
app/services/notification_service.rb
app/services/notification_service.rb
+1
-1
spec/features/issues_spec.rb
spec/features/issues_spec.rb
+1
-1
No files found.
app/models/note.rb
View file @
c4c877e4
...
...
@@ -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
}
_"
...
...
app/services/issues/base_service.rb
View file @
c4c877e4
...
...
@@ -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
app/services/issues/update_service.rb
View file @
c4c877e4
...
...
@@ -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
)
...
...
app/services/merge_requests/base_service.rb
View file @
c4c877e4
...
...
@@ -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
app/services/merge_requests/update_service.rb
View file @
c4c877e4
...
...
@@ -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
)
...
...
app/services/notification_service.rb
View file @
c4c877e4
...
...
@@ -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
...
...
spec/features/issues_spec.rb
View file @
c4c877e4
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment