Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
b18e513f1293
Commit
bfc96a1b
authored
Apr 16, 2019
by
Heinrich Lee Yu
Browse files
Set correct timestamps when creating past issues
Sets `system_note_timestamp` from `created_at`
parent
525c0f92cc89
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/models/concerns/noteable.rb
View file @
b18e513f
...
...
@@ -13,7 +13,7 @@ def replyable_types
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
...
...
changelogs/unreleased/58361-issue-create-system-note-timestamp.yml
0 → 100644
View file @
b18e513f
---
title
:
Fix system notes timestamp when creating issue in the past
merge_request
:
27406
author
:
type
:
fixed
lib/api/issues.rb
View file @
b18e513f
...
...
@@ -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
)
...
...
spec/requests/api/issues_spec.rb
View file @
b18e513f
...
...
@@ -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/
#{
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
...
...
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