diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/presenters/blob_presenter_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/presenters/blob_presenter_spec.rb')
-rw-r--r-- | spec/presenters/blob_presenter_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb index 498b2a32a0e..88dafb7ea1f 100644 --- a/spec/presenters/blob_presenter_spec.rb +++ b/spec/presenters/blob_presenter_spec.rb @@ -252,6 +252,18 @@ RSpec.describe BlobPresenter do end end + describe '#highlight_and_trim' do + let(:git_blob) { blob.__getobj__ } + + it 'returns trimmed content for longer line' do + trimmed_lines = git_blob.data.split("\n").map { |line| line[0, 55] }.join("\n") + + expect(Gitlab::Highlight).to receive(:highlight).with('files/ruby/regex.rb', "#{trimmed_lines}\n", plain: nil, language: 'ruby', context: { ellipsis_svg: "svg_icon", ellipsis_indexes: [21, 26, 49] }) + + presenter.highlight_and_trim(ellipsis_svg: "svg_icon", trim_length: 55) + end + end + describe '#blob_language' do subject { presenter.blob_language } |