debian-mirror-gitlab/spec/features/snippets/embedded_snippet_spec.rb

37 lines
1.3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Embedded Snippets', feature_category: :source_code_management do
2020-10-24 23:57:45 +05:30
let_it_be(:snippet) { create(:personal_snippet, :public, :repository) }
2021-09-30 23:02:18 +05:30
2020-10-24 23:57:45 +05:30
let(:blobs) { snippet.blobs.first(3) }
2018-10-15 14:42:47 +05:30
it 'loads snippet', :js do
2020-10-24 23:57:45 +05:30
expect_any_instance_of(Snippet).to receive(:blobs).and_return(blobs)
script_url = "http://#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}#{snippet_path(snippet, format: 'js')}"
2018-10-15 14:42:47 +05:30
embed_body = "<html><body><script src=\"#{script_url}\"></script></body></html>"
rack_app = proc do
['200', { 'Content-Type' => 'text/html' }, [embed_body]]
end
server = Capybara::Server.new(rack_app)
server.boot
visit("http://#{server.host}:#{server.port}/embedded_snippet.html")
2020-10-24 23:57:45 +05:30
wait_for_requests
aggregate_failures do
blobs.each do |blob|
expect(page).to have_content(blob.path)
expect(page.find(".snippet-file-content .blob-content[data-blob-id='#{blob.id}'] code")).to have_content(blob.data.squish)
2021-09-30 23:02:18 +05:30
expect(page).to have_link('Open raw', href: %r{-/snippets/#{snippet.id}/raw/master/#{blob.path}})
expect(page).to have_link('Download', href: %r{-/snippets/#{snippet.id}/raw/master/#{blob.path}\?inline=false})
2020-10-24 23:57:45 +05:30
end
end
2018-10-15 14:42:47 +05:30
end
end