Allow back dating notes on creation
This commit is contained in:
parent
28a7fe25fd
commit
c1467f5d97
|
@ -23,6 +23,7 @@ v 8.7.0 (unreleased)
|
|||
- Fix Error 500 after renaming a project path (Stan Hu)
|
||||
- Fix a bug whith trailing slash in teamcity_url (Charles May)
|
||||
- Allow back dating on issues when created or updated through the API
|
||||
- Allow back dating on issue notes when created through the API
|
||||
- Fix avatar stretching by providing a cropping feature
|
||||
- API: Expose `subscribed` for issues and merge requests (Robert Schilling)
|
||||
- Allow SAML to handle external users based on user's information !3530
|
||||
|
|
|
@ -89,6 +89,7 @@ Parameters:
|
|||
- `id` (required) - The ID of a project
|
||||
- `issue_id` (required) - The ID of an issue
|
||||
- `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 issue note
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ module API
|
|||
# id (required) - The ID of a project
|
||||
# noteable_id (required) - The ID of an issue or snippet
|
||||
# body (required) - The content of a note
|
||||
# created_at (optional) - The date
|
||||
# Example Request:
|
||||
# POST /projects/:id/issues/:noteable_id/notes
|
||||
# POST /projects/:id/snippets/:noteable_id/notes
|
||||
|
@ -73,6 +74,10 @@ module API
|
|||
noteable_id: params[noteable_id_str]
|
||||
}
|
||||
|
||||
if params[:created_at] && (current_user.is_admin? || user_project.owner == current_user)
|
||||
opts[:created_at] = params[:created_at]
|
||||
end
|
||||
|
||||
@note = ::Notes::CreateService.new(user_project, current_user, opts).execute
|
||||
|
||||
if @note.valid?
|
||||
|
|
|
@ -158,6 +158,19 @@ describe API::API, api: true do
|
|||
post api("/projects/#{project.id}/issues/#{issue.id}/notes"), body: 'hi!'
|
||||
expect(response.status).to eq(401)
|
||||
end
|
||||
|
||||
context 'when an admin or owner makes the request' do
|
||||
it 'accepts the creation date to be set' do
|
||||
creation_time = 2.weeks.ago
|
||||
post api("/projects/#{project.id}/issues/#{issue.id}/notes", user),
|
||||
body: 'hi!', created_at: creation_time
|
||||
expect(response.status).to eq(201)
|
||||
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_within(1.second).of(creation_time)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "when noteable is a Snippet" do
|
||||
|
|
Loading…
Reference in New Issue