2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2016-11-03 02:34:52 -04:00
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe 'Public Snippets', :js do
|
2020-10-08 08:08:31 -04:00
|
|
|
let(:public_snippet) { create(:personal_snippet, :public, :repository) }
|
|
|
|
let(:content) { public_snippet.blobs.first.data.strip! }
|
2019-12-05 22:08:02 -05:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'Unauthenticated user should see public snippets' do
|
2020-10-08 08:08:31 -04:00
|
|
|
url = Gitlab::UrlBuilder.build(public_snippet)
|
2016-11-03 02:34:52 -04:00
|
|
|
|
|
|
|
visit snippet_path(public_snippet)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-11-03 02:34:52 -04:00
|
|
|
|
2020-10-08 08:08:31 -04: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 02:34:52 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'Unauthenticated user should see raw public snippets' do
|
2016-11-03 02:34:52 -04:00
|
|
|
visit raw_snippet_path(public_snippet)
|
|
|
|
|
2020-10-08 08:08:31 -04:00
|
|
|
expect(page).to have_content(content)
|
2016-11-03 02:34:52 -04:00
|
|
|
end
|
|
|
|
end
|