2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 07:56:52 +00:00
|
|
|
require 'spec_helper'
|
2016-11-03 06:34:52 +00:00
|
|
|
|
2020-06-03 18:08:28 +00:00
|
|
|
RSpec.describe 'Public Snippets', :js do
|
2020-10-08 12:08:31 +00:00
|
|
|
let(:public_snippet) { create(:personal_snippet, :public, :repository) }
|
|
|
|
let(:content) { public_snippet.blobs.first.data.strip! }
|
2019-12-06 03:08:02 +00:00
|
|
|
|
2020-12-09 18:09:48 +00:00
|
|
|
it 'unauthenticated user should see public snippets' do
|
2020-10-08 12:08:31 +00:00
|
|
|
url = Gitlab::UrlBuilder.build(public_snippet)
|
2016-11-03 06:34:52 +00:00
|
|
|
|
|
|
|
visit snippet_path(public_snippet)
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2016-11-03 06:34:52 +00:00
|
|
|
|
2020-10-08 12:08:31 +00:00
|
|
|
expect(page).to have_content(content)
|
|
|
|
click_button('Embed')
|
|
|
|
expect(page).to have_field('Embed', readonly: true, with: "<script src=\"#{url}.js\"></script>")
|
|
|
|
expect(page).to have_field('Share', readonly: true, with: url)
|
2016-11-03 06:34:52 +00:00
|
|
|
end
|
|
|
|
|
2020-12-09 18:09:48 +00:00
|
|
|
it 'unauthenticated user should see raw public snippets' do
|
2016-11-03 06:34:52 +00:00
|
|
|
visit raw_snippet_path(public_snippet)
|
|
|
|
|
2020-10-08 12:08:31 +00:00
|
|
|
expect(page).to have_content(content)
|
2016-11-03 06:34:52 +00:00
|
|
|
end
|
|
|
|
end
|