diff --git a/ee/lib/search/elastic/references/work_item.rb b/ee/lib/search/elastic/references/work_item.rb index 2bf6964ed67f811714f9173cdb59da9858abbb7f..a2ea3641c407b43b8e664a0f2f9862cdd4f84d68 100644 --- a/ee/lib/search/elastic/references/work_item.rb +++ b/ee/lib/search/elastic/references/work_item.rb @@ -69,7 +69,7 @@ def model_klass private def populate_notes(target, data) - notes_internal, notes = target.notes.partition(&:internal) + notes_internal, notes = target.notes.user.partition(&:internal) internal_notes = notes_internal.sort_by(&:created_at).reverse.map(&:note).join("\n").presence data['notes_internal'] = internal_notes.truncate_bytes(NOTES_MAXIMUM_BYTES) if internal_notes diff --git a/ee/spec/lib/search/elastic/references/work_item_spec.rb b/ee/spec/lib/search/elastic/references/work_item_spec.rb index 0541f60eebd09d7eab8bcf0eaced3df72931b40c..ebad7060f6b124ce6b97be1c8aa5af444114c623 100644 --- a/ee/spec/lib/search/elastic/references/work_item_spec.rb +++ b/ee/spec/lib/search/elastic/references/work_item_spec.rb @@ -95,7 +95,6 @@ let_it_be(:note1) { create(:note_on_issue, noteable: project_work_item, project: project, note: 'Some pig') } let_it_be(:note2) { create(:note_on_issue, noteable: project_work_item, project: project, note: 'Terrific') } let_it_be(:note3) { create(:note, :internal, noteable: project_work_item, project: project, note: "Radiant") } - let(:expected_hash) do base_work_item_hash.merge( root_namespace_id: project_work_item.namespace.root_ancestor.id, @@ -121,6 +120,12 @@ expect(indexed_json[:notes_internal]).to eq("Newest\n…") end + it 'does not include system notes' do + create(:note, :system, noteable: project_work_item, project: project, note: "Enchanting!") + + expect(indexed_json[:notes]).not_to include('Enchanting!') + end + context 'when add_work_item_type_correct_id migration is not complete' do before do set_elasticsearch_migration_to :add_work_item_type_correct_id, including: false