# frozen_string_literal: true require 'spec_helper' RSpec.describe BlobHelper do include TreeHelper describe '#highlight' do it 'wraps highlighted content' do expect(helper.highlight('test.rb', '52')).to eq(%q[
52
]) end it 'handles plain version' do expect(helper.highlight('test.rb', '52', plain: true)).to eq(%q[
52
]) end end describe "#sanitize_svg_data" do let(:input_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'unsanitized.svg') } let(:data) { File.read(input_svg_path) } let(:expected_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'sanitized.svg') } let(:expected) { File.read(expected_svg_path) } it 'retains essential elements' do expect(sanitize_svg_data(data)).to eq(expected) end end describe "#edit_blob_link" do let(:namespace) { create(:namespace, name: 'gitlab') } let(:project) { create(:project, :repository, namespace: namespace) } subject(:link) { helper.edit_blob_button(project, 'master', 'README.md') } before do allow(helper).to receive(:current_user).and_return(nil) allow(helper).to receive(:can?).and_return(true) allow(helper).to receive(:can_collaborate_with_project?).and_return(true) end it 'verifies blob is text' do expect(helper).not_to receive(:blob_text_viewable?) button = helper.edit_blob_button(project, 'refs/heads/master', 'README.md') expect(button).to start_with('