summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Davila <rdavila84@gmail.com>2017-03-14 11:56:15 -0500
committerRuben Davila <rdavila84@gmail.com>2017-03-14 11:56:15 -0500
commitdd53a9c0132d48393ca11e29825b599a5a1454a7 (patch)
tree9f35948e592d4d53dc0c187082bb3505a30ab30b
parentffcddb295950729dbc4ee7a3c0e32f7dec00da99 (diff)
downloadgitlab-ce-27271-missing-time-spent-in-issue-webhook.tar.gz
Include time tracking attributes in webhooks payload27271-missing-time-spent-in-issue-webhook
-rw-r--r--app/models/issue.rb8
-rw-r--r--app/models/merge_request.rb5
-rw-r--r--changelogs/unreleased/27271-missing-time-spent-in-issue-webhook.yml4
-rw-r--r--spec/models/issue_spec.rb11
-rw-r--r--spec/models/merge_request_spec.rb6
5 files changed, 31 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 0f7a26ee3e1..2cc237635f9 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -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
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 0f7b8311588..4759829a15c 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -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
diff --git a/changelogs/unreleased/27271-missing-time-spent-in-issue-webhook.yml b/changelogs/unreleased/27271-missing-time-spent-in-issue-webhook.yml
new file mode 100644
index 00000000000..4ea52a70e89
--- /dev/null
+++ b/changelogs/unreleased/27271-missing-time-spent-in-issue-webhook.yml
@@ -0,0 +1,4 @@
+---
+title: Include time tracking attributes in webhooks payload
+merge_request: 9942
+author:
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index bba9058f394..898a9c8da35 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -620,4 +620,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
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index fcaf4c71182..24e7c1b17d9 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -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