From f34b26bb882947bcc1126de19fa55eb8763af32e Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 23 Feb 2023 03:12:37 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/services/system_notes/commit_service_spec.rb | 82 ++++++++++++++++++++--- 1 file changed, 74 insertions(+), 8 deletions(-) (limited to 'spec/services/system_notes/commit_service_spec.rb') diff --git a/spec/services/system_notes/commit_service_spec.rb b/spec/services/system_notes/commit_service_spec.rb index 0399603980d..8dfb83f63fe 100644 --- a/spec/services/system_notes/commit_service_spec.rb +++ b/spec/services/system_notes/commit_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe SystemNotes::CommitService do +RSpec.describe SystemNotes::CommitService, feature_category: :code_review_workflow do let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, :repository, group: group) } let_it_be(:author) { create(:user) } @@ -13,7 +13,7 @@ RSpec.describe SystemNotes::CommitService do subject { commit_service.add_commits(new_commits, old_commits, oldrev) } let(:noteable) { create(:merge_request, source_project: project, target_project: project) } - let(:new_commits) { noteable.commits } + let(:new_commits) { create_commits(10) } let(:old_commits) { [] } let(:oldrev) { nil } @@ -43,6 +43,48 @@ RSpec.describe SystemNotes::CommitService do expect(decoded_note_content).to include("
  • #{commit.short_id} - #{commit.title}
  • ") end end + + context 'with HTML content' do + let(:new_commits) { [double(title: '
    This is a test
    ', short_id: '12345678')] } + + it 'escapes HTML titles' do + expect(note_lines[1]).to eq("") + end + end + + context 'with one commit exceeding the NEW_COMMIT_DISPLAY_LIMIT' do + let(:new_commits) { create_commits(11) } + let(:earlier_commit_summary_line) { note_lines[1] } + + it 'includes the truncated new commits summary' do + expect(earlier_commit_summary_line).to start_with("