Commit 8b2e2209 authored by Stan Hu's avatar Stan Hu

Merge branch '347473-fix-add-spent-time-api' into 'master'

Set spent time when using timelogs API

See merge request gitlab-org/gitlab!76400
parents 5732b016 655821f3
# frozen_string_literal: true
class UpdateTimelogsSpentAtDefault < Gitlab::Database::Migration[1.0]
def change
change_column_default(:timelogs, :spent_at, from: nil, to: -> { 'NOW()' })
end
end
2267855b2f12747b1f31f392677fac4d4f82ee234d7c54fd209b8bad417c8c75
\ No newline at end of file
......@@ -19916,7 +19916,7 @@ CREATE TABLE timelogs (
updated_at timestamp without time zone NOT NULL,
issue_id integer,
merge_request_id integer,
spent_at timestamp without time zone,
spent_at timestamp without time zone DEFAULT now(),
note_id integer,
project_id integer,
summary text,
......@@ -21,7 +21,7 @@ RSpec.describe Timelog do
it { expect(subject.project_id).not_to be_nil }
describe 'Issuable validation' do
describe 'validation' do
it 'is invalid if issue_id and merge_request_id are missing' do
subject.attributes = { issue: nil, merge_request: nil }
......@@ -139,4 +139,14 @@ RSpec.describe Timelog do
time + 1.day
end
end
describe 'hooks' do
describe '.set_project' do
it 'populates project with issuable project' do
timelog = create(:issue_timelog, issue: issue)
expect(timelog.project_id).to be(timelog.issue.project_id)
end
end
end
end
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