Commit bfc96a1b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu
Browse files

Set correct timestamps when creating past issues

Sets `system_note_timestamp` from `created_at`
parent 525c0f92cc89
......@@ -13,7 +13,7 @@ def replyable_types
# 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 || # rubocop:disable Gitlab/ModuleWithInstanceVariables
title: Fix system notes timestamp when creating issue in the past
merge_request: 27406
type: fixed
......@@ -192,6 +192,7 @@ def find_issues(args = {})
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 @@
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/#{}/issues", admin), params: params
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)
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)
context 'by a project owner' 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