diff options
author | Rémy Coutable <remy@rymai.me> | 2018-07-12 09:26:09 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-07-12 09:26:09 +0000 |
commit | cfe2121978a235d93d9bacefde37702bfa1f4848 (patch) | |
tree | f156e2fc0ced165327e9a48ce3ae153608ff2bb4 | |
parent | d2c5ac61cd964e6c3ff22021734002b6e591a128 (diff) | |
parent | 37af75a2e024bf35f09e6f014626019e960ad9b9 (diff) | |
download | gitlab-ce-cfe2121978a235d93d9bacefde37702bfa1f4848.tar.gz |
Merge branch '46930-fix-updated_at-if-created_at-is-set-note-api' into 'master'
Resolve "do not set updated_at when creating note"
Closes #46930
See merge request gitlab-org/gitlab-ce!20322
-rw-r--r-- | changelogs/unreleased/46930-fix-updated_at-if-created_at-is-set-note-api.yml | 5 | ||||
-rw-r--r-- | doc/api/notes.md | 2 | ||||
-rw-r--r-- | lib/api/helpers/notes_helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/shared_examples/requests/api/notes.rb | 1 |
4 files changed, 10 insertions, 0 deletions
diff --git a/changelogs/unreleased/46930-fix-updated_at-if-created_at-is-set-note-api.yml b/changelogs/unreleased/46930-fix-updated_at-if-created_at-is-set-note-api.yml new file mode 100644 index 00000000000..d95714a5267 --- /dev/null +++ b/changelogs/unreleased/46930-fix-updated_at-if-created_at-is-set-note-api.yml @@ -0,0 +1,5 @@ +--- +title: Fix updated_at if created_at is set for Note API +merge_request: +author: +type: fixed diff --git a/doc/api/notes.md b/doc/api/notes.md index d29c5b94915..c271d46688f 100644 --- a/doc/api/notes.md +++ b/doc/api/notes.md @@ -218,6 +218,7 @@ Parameters: - `id` (required) - The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) - `snippet_id` (required) - The ID of a snippet - `body` (required) - The content of a note +- `created_at` (optional) - Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z ```bash curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/5/snippet/11/notes?body=note @@ -340,6 +341,7 @@ Parameters: - `id` (required) - The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) - `merge_request_iid` (required) - The IID of a merge request - `body` (required) - The content of a note +- `created_at` (optional) - Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z ### Modify existing merge request note diff --git a/lib/api/helpers/notes_helpers.rb b/lib/api/helpers/notes_helpers.rb index b4bfb677d72..e2984b08eca 100644 --- a/lib/api/helpers/notes_helpers.rb +++ b/lib/api/helpers/notes_helpers.rb @@ -97,6 +97,8 @@ module API current_user.admin? || parent.owned_by?(current_user) end + opts[:updated_at] = opts[:created_at] if opts[:created_at] + project = parent if parent.is_a?(Project) ::Notes::CreateService.new(project, current_user, opts).execute end diff --git a/spec/support/shared_examples/requests/api/notes.rb b/spec/support/shared_examples/requests/api/notes.rb index 79b2196660c..1b563021244 100644 --- a/spec/support/shared_examples/requests/api/notes.rb +++ b/spec/support/shared_examples/requests/api/notes.rb @@ -121,6 +121,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) + expect(Time.parse(json_response['updated_at'])).to be_like_time(creation_time) end end |