Set correct timestamps when creating past issues
Sets `system_note_timestamp` from `created_at`
This commit is contained in:
parent
7994db791a
commit
e0b6838a90
4 changed files with 16 additions and 2 deletions
|
@ -13,7 +13,7 @@ module Noteable
|
|||
end
|
||||
end
|
||||
|
||||
# The timestamp of the note (e.g. the :updated_at attribute if provided via
|
||||
# The timestamp of the note (e.g. the :created_at or :updated_at attribute if provided via
|
||||
# API call)
|
||||
def system_note_timestamp
|
||||
@system_note_timestamp || Time.now # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix system notes timestamp when creating issue in the past
|
||||
merge_request: 27406
|
||||
author:
|
||||
type: fixed
|
|
@ -192,6 +192,7 @@ module API
|
|||
params.delete(:iid) unless current_user.can?(:set_issue_iid, user_project)
|
||||
|
||||
issue_params = declared_params(include_missing: false)
|
||||
issue_params[:system_note_timestamp] = params[:created_at]
|
||||
|
||||
issue_params = convert_parameters_from_legacy_format(issue_params)
|
||||
|
||||
|
|
|
@ -1480,12 +1480,20 @@ describe API::Issues do
|
|||
let(:params) { { title: 'new issue', labels: 'label, label2', created_at: creation_time } }
|
||||
|
||||
context 'by an admin' do
|
||||
it 'sets the creation time on the new issue' do
|
||||
before do
|
||||
post api("/projects/#{project.id}/issues", admin), params: params
|
||||
end
|
||||
|
||||
it 'sets the creation time on the new issue' do
|
||||
expect(response).to have_gitlab_http_status(201)
|
||||
expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
|
||||
end
|
||||
|
||||
it 'sets the system notes timestamp based on creation time' do
|
||||
issue = Issue.find(json_response['id'])
|
||||
|
||||
expect(issue.resource_label_events.last.created_at).to be_like_time(creation_time)
|
||||
end
|
||||
end
|
||||
|
||||
context 'by a project owner' do
|
||||
|
|
Loading…
Reference in a new issue