diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/lib/gitlab/diff/rendered/notebook/diff_file_spec.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/lib/gitlab/diff/rendered/notebook/diff_file_spec.rb')
-rw-r--r-- | spec/lib/gitlab/diff/rendered/notebook/diff_file_spec.rb | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/spec/lib/gitlab/diff/rendered/notebook/diff_file_spec.rb b/spec/lib/gitlab/diff/rendered/notebook/diff_file_spec.rb index 1b74e24bf81..c38684a6dc3 100644 --- a/spec/lib/gitlab/diff/rendered/notebook/diff_file_spec.rb +++ b/spec/lib/gitlab/diff/rendered/notebook/diff_file_spec.rb @@ -66,7 +66,7 @@ RSpec.describe Gitlab::Diff::Rendered::Notebook::DiffFile do context 'timeout' do it 'utilizes timeout for web' do - expect(Timeout).to receive(:timeout).with(described_class::RENDERED_TIMEOUT_FOREGROUND).and_call_original + expect(Timeout).to receive(:timeout).with(Gitlab::RenderTimeout::FOREGROUND).and_call_original nb_file.diff end @@ -133,7 +133,7 @@ RSpec.describe Gitlab::Diff::Rendered::Notebook::DiffFile do end context 'assigns the correct position' do - it 'computes de first line where the remove would appear' do + it 'computes the first line where the remove would appear' do expect(nb_file.highlighted_diff_lines[0].old_pos).to eq(3) expect(nb_file.highlighted_diff_lines[0].new_pos).to eq(3) @@ -142,8 +142,29 @@ RSpec.describe Gitlab::Diff::Rendered::Notebook::DiffFile do end end - it 'computes de first line where the remove would appear' do - expect(nb_file.highlighted_diff_lines.map(&:text).join('')).to include('[Hidden Image Output]') + context 'has image' do + it 'replaces rich text with img to the embedded image' do + expect(nb_file.highlighted_diff_lines[58].rich_text).to include('<img') + end + + it 'adds image to src' do + img = 'data:image/png;base64,some_image_here' + allow(diff).to receive(:diff).and_return("@@ -1,76 +1,74 @@\n ![](#{img})") + + expect(nb_file.highlighted_diff_lines[0].rich_text).to include("<img src=\"#{img}\"") + end + end + + context 'when embedded image has injected html' do + let(:commit) { project.commit("4963fefc990451a8ad34289ce266b757456fc88c") } + + it 'prevents injected html to be rendered as html' do + expect(nb_file.highlighted_diff_lines[45].rich_text).not_to include('<div>Hello') + end + + it 'keeps the injected html as part of the string' do + expect(nb_file.highlighted_diff_lines[45].rich_text).to end_with('/div>">') + end end end end |