diff options
author | Sean McGivern <sean@gitlab.com> | 2019-06-19 14:17:08 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-06-20 13:50:28 +0100 |
commit | da4702493d046e6de24c0a071b0162818e9d990c (patch) | |
tree | 78af36d3f26d4ce25060886cbd76ee09e390ee7e /spec/lib/gitlab/data_builder | |
parent | 7277c9b0681186aea3e67ef7ec2dc2b597b5a98c (diff) | |
download | gitlab-ce-da4702493d046e6de24c0a071b0162818e9d990c.tar.gz |
Fix label serialisation in issue and note hooks
We were not calling hook_attrs on the labels correctly. Specs were
passing because the issues under test did not have any labels!
Diffstat (limited to 'spec/lib/gitlab/data_builder')
-rw-r--r-- | spec/lib/gitlab/data_builder/note_spec.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/spec/lib/gitlab/data_builder/note_spec.rb b/spec/lib/gitlab/data_builder/note_spec.rb index ed9a1e23529..1b5dd2538e0 100644 --- a/spec/lib/gitlab/data_builder/note_spec.rb +++ b/spec/lib/gitlab/data_builder/note_spec.rb @@ -38,9 +38,11 @@ describe Gitlab::DataBuilder::Note do end describe 'When asking for a note on issue' do + let(:label) { create(:label, project: project) } + let(:issue) do - create(:issue, created_at: fixed_time, updated_at: fixed_time, - project: project) + create(:labeled_issue, created_at: fixed_time, updated_at: fixed_time, + project: project, labels: [label]) end let(:note) do @@ -48,13 +50,16 @@ describe Gitlab::DataBuilder::Note do end it 'returns the note and issue-specific data' do + without_timestamps = lambda { |label| label.except('created_at', 'updated_at') } + hook_attrs = issue.reload.hook_attrs + expect(data).to have_key(:issue) - expect(data[:issue].except('updated_at')) - .to eq(issue.reload.hook_attrs.except('updated_at')) + expect(data[:issue].except('updated_at', 'labels')) + .to eq(hook_attrs.except('updated_at', 'labels')) expect(data[:issue]['updated_at']) - .to be >= issue.hook_attrs['updated_at'] - expect(data[:issue]['labels']) - .to eq(issue.hook_attrs['labels']) + .to be >= hook_attrs['updated_at'] + expect(data[:issue]['labels'].map(&without_timestamps)) + .to eq(hook_attrs['labels'].map(&without_timestamps)) end context 'with confidential issue' do |