Commit 10966544 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'ce-to-ee-2018-09-10' into 'master'

CE upstream - 2018-09-10 00:21 UTC

See merge request gitlab-org/gitlab-ee!7298
parents 1eaf66eb efefc1a6
...@@ -23,7 +23,8 @@ module SystemNoteHelper ...@@ -23,7 +23,8 @@ module SystemNoteHelper
'outdated' => 'pencil-square', 'outdated' => 'pencil-square',
'duplicate' => 'issue-duplicate', 'duplicate' => 'issue-duplicate',
'locked' => 'lock', 'locked' => 'lock',
'unlocked' => 'lock-open' 'unlocked' => 'lock-open',
'due_date' => 'calendar'
}.freeze }.freeze
def system_note_icon_name(note) def system_note_icon_name(note)
......
...@@ -18,7 +18,7 @@ class SystemNoteMetadata < ActiveRecord::Base ...@@ -18,7 +18,7 @@ class SystemNoteMetadata < ActiveRecord::Base
commit description merge confidential visible label assignee cross_reference commit description merge confidential visible label assignee cross_reference
title time_tracking branch milestone discussion task moved title time_tracking branch milestone discussion task moved
opened closed merged duplicate locked unlocked opened closed merged duplicate locked unlocked
outdated tag outdated tag due_date
].freeze ].freeze
validates :note, presence: true validates :note, presence: true
......
...@@ -18,6 +18,7 @@ module Issuable ...@@ -18,6 +18,7 @@ module Issuable
create_labels_note(old_labels) if issuable.labels != old_labels create_labels_note(old_labels) if issuable.labels != old_labels
create_discussion_lock_note if issuable.previous_changes.include?('discussion_locked') create_discussion_lock_note if issuable.previous_changes.include?('discussion_locked')
create_milestone_note if issuable.previous_changes.include?('milestone_id') create_milestone_note if issuable.previous_changes.include?('milestone_id')
create_due_date_note if issuable.previous_changes.include?('due_date')
end end
private private
...@@ -91,6 +92,10 @@ module Issuable ...@@ -91,6 +92,10 @@ module Issuable
SystemNoteService.change_milestone(issuable, issuable.project, current_user, issuable.milestone) SystemNoteService.change_milestone(issuable, issuable.project, current_user, issuable.milestone)
end end
def create_due_date_note
SystemNoteService.change_due_date(issuable, issuable.project, current_user, issuable.due_date)
end
def create_discussion_lock_note def create_discussion_lock_note
SystemNoteService.discussion_lock(issuable, current_user) SystemNoteService.discussion_lock(issuable, current_user)
end end
......
...@@ -120,6 +120,26 @@ module SystemNoteService ...@@ -120,6 +120,26 @@ module SystemNoteService
create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone')) create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone'))
end end
# Called when the due_date of a Noteable is changed
#
# noteable - Noteable object
# project - Project owning noteable
# author - User performing the change
# due_date - Due date being assigned, or nil
#
# Example Note text:
#
# "removed due date"
#
# "changed due date to September 20, 2018"
#
# Returns the created Note object
def change_due_date(noteable, project, author, due_date)
body = due_date ? "changed due date to #{due_date.to_s(:long)}" : 'removed due date'
create_note(NoteSummary.new(noteable, project, author, body, action: 'due_date'))
end
# Called when the estimated time of a Noteable is changed # Called when the estimated time of a Noteable is changed
# #
# noteable - Noteable object # noteable - Noteable object
......
---
title: Add system note when due date is changed
merge_request:
author: Eva Kadlecova
type: added
...@@ -30,7 +30,7 @@ describe 'Project > Members > Invite group', :js do ...@@ -30,7 +30,7 @@ describe 'Project > Members > Invite group', :js do
sign_in(maintainer) sign_in(maintainer)
end end
context 'when the group has "Share group lock" disabled' do context 'when the group has "Share with group lock" disabled' do
it_behaves_like 'the project can be shared with groups' it_behaves_like 'the project can be shared with groups'
it 'the project can be shared with another group' do it 'the project can be shared with another group' do
...@@ -48,7 +48,7 @@ describe 'Project > Members > Invite group', :js do ...@@ -48,7 +48,7 @@ describe 'Project > Members > Invite group', :js do
end end
end end
context 'when the group has "Share group lock" enabled' do context 'when the group has "Share with group lock" enabled' do
before do before do
project.namespace.update_column(:share_with_group_lock, true) project.namespace.update_column(:share_with_group_lock, true)
end end
...@@ -68,12 +68,12 @@ describe 'Project > Members > Invite group', :js do ...@@ -68,12 +68,12 @@ describe 'Project > Members > Invite group', :js do
sign_in(maintainer) sign_in(maintainer)
end end
context 'when the root_group has "Share group lock" disabled' do context 'when the root_group has "Share with group lock" disabled' do
context 'when the subgroup has "Share group lock" disabled' do context 'when the subgroup has "Share with group lock" disabled' do
it_behaves_like 'the project can be shared with groups' it_behaves_like 'the project can be shared with groups'
end end
context 'when the subgroup has "Share group lock" enabled' do context 'when the subgroup has "Share with group lock" enabled' do
before do before do
subgroup.update_column(:share_with_group_lock, true) subgroup.update_column(:share_with_group_lock, true)
end end
...@@ -82,16 +82,16 @@ describe 'Project > Members > Invite group', :js do ...@@ -82,16 +82,16 @@ describe 'Project > Members > Invite group', :js do
end end
end end
context 'when the root_group has "Share group lock" enabled' do context 'when the root_group has "Share with group lock" enabled' do
before do before do
root_group.update_column(:share_with_group_lock, true) root_group.update_column(:share_with_group_lock, true)
end end
context 'when the subgroup has "Share group lock" disabled (parent overridden)' do context 'when the subgroup has "Share with group lock" disabled (parent overridden)' do
it_behaves_like 'the project can be shared with groups' it_behaves_like 'the project can be shared with groups'
end end
context 'when the subgroup has "Share group lock" enabled' do context 'when the subgroup has "Share with group lock" enabled' do
before do before do
subgroup.update_column(:share_with_group_lock, true) subgroup.update_column(:share_with_group_lock, true)
end end
......
...@@ -251,6 +251,30 @@ describe SystemNoteService do ...@@ -251,6 +251,30 @@ describe SystemNoteService do
end end
end end
describe '.change_due_date' do
subject { described_class.change_due_date(noteable, project, author, due_date) }
let(:due_date) { Date.today }
it_behaves_like 'a system note' do
let(:action) { 'due_date' }
end
context 'when due date added' do
it 'sets the note text' do
expect(subject.note).to eq "changed due date to #{Date.today.to_s(:long)}"
end
end
context 'when due date removed' do
let(:due_date) { nil }
it 'sets the note text' do
expect(subject.note).to eq 'removed due date'
end
end
end
describe '.change_status' do describe '.change_status' do
subject { described_class.change_status(noteable, project, author, status, source) } subject { described_class.change_status(noteable, project, author, status, source) }
......
...@@ -5,6 +5,8 @@ shared_examples 'instance statistics availability' do ...@@ -5,6 +5,8 @@ shared_examples 'instance statistics availability' do
before do before do
sign_in(user) sign_in(user)
stub_application_setting(usage_ping_enabled: true)
end end
describe 'GET #index' do describe 'GET #index' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment