summaryrefslogtreecommitdiff
path: root/spec/models/concerns/issuable_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/models/concerns/issuable_spec.rb
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
downloadgitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/models/concerns/issuable_spec.rb')
-rw-r--r--spec/models/concerns/issuable_spec.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 74ee7a87b7b..96d3e2b7b1b 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe Issuable do
+RSpec.describe Issuable do
include ProjectForksHelper
let(:issuable_class) { Issue }
@@ -416,6 +416,27 @@ describe Issuable do
describe '#to_hook_data' do
let(:builder) { double }
+ context 'when old_associations is empty' do
+ let(:label) { create(:label) }
+
+ before do
+ issue.update!(labels: [label])
+ issue.assignees << user
+ issue.spend_time(duration: 2, user_id: user.id, spent_at: Time.current)
+ expect(Gitlab::HookData::IssuableBuilder)
+ .to receive(:new).with(issue).and_return(builder)
+ end
+
+ it 'delegates to Gitlab::HookData::IssuableBuilder#build and does not set labels, assignees, nor total_time_spent' do
+ expect(builder).to receive(:build).with(
+ user: user,
+ changes: {})
+
+ # In some cases, old_associations is empty, e.g. on a close event
+ issue.to_hook_data(user)
+ end
+ end
+
context 'labels are updated' do
let(:labels) { create_list(:label, 2) }