Merge branch '27271-missing-time-spent-in-issue-webhook' into 'master'

Include time tracking attributes in webhooks payload

Closes #27271

See merge request !9942
This commit is contained in:
Douwe Maan 2017-03-15 15:29:16 +00:00
commit b7123a8f59
5 changed files with 31 additions and 3 deletions

View file

@ -58,7 +58,13 @@ class Issue < ActiveRecord::Base
end
def hook_attrs
attributes
attrs = {
total_time_spent: total_time_spent,
human_total_time_spent: human_total_time_spent,
human_time_estimate: human_time_estimate
}
attributes.merge!(attrs)
end
def self.reference_prefix

View file

@ -523,7 +523,10 @@ class MergeRequest < ActiveRecord::Base
source: source_project.try(:hook_attrs),
target: target_project.hook_attrs,
last_commit: nil,
work_in_progress: work_in_progress?
work_in_progress: work_in_progress?,
total_time_spent: total_time_spent,
human_total_time_spent: human_total_time_spent,
human_time_estimate: human_time_estimate
}
if diff_head_commit

View file

@ -0,0 +1,4 @@
---
title: Include time tracking attributes in webhooks payload
merge_request: 9942
author:

View file

@ -635,4 +635,15 @@ describe Issue, models: true do
end
end
end
describe '#hook_attrs' do
let(:attrs_hash) { subject.hook_attrs }
it 'includes time tracking attrs' do
expect(attrs_hash).to include(:total_time_spent)
expect(attrs_hash).to include(:human_time_estimate)
expect(attrs_hash).to include(:human_total_time_spent)
expect(attrs_hash).to include('time_estimate')
end
end
end

View file

@ -542,7 +542,7 @@ describe MergeRequest, models: true do
end
describe "#hook_attrs" do
let(:attrs_hash) { subject.hook_attrs.to_h }
let(:attrs_hash) { subject.hook_attrs }
[:source, :target].each do |key|
describe "#{key} key" do
@ -558,6 +558,10 @@ describe MergeRequest, models: true do
expect(attrs_hash).to include(:target)
expect(attrs_hash).to include(:last_commit)
expect(attrs_hash).to include(:work_in_progress)
expect(attrs_hash).to include(:total_time_spent)
expect(attrs_hash).to include(:human_time_estimate)
expect(attrs_hash).to include(:human_total_time_spent)
expect(attrs_hash).to include('time_estimate')
end
end