summaryrefslogtreecommitdiff
path: root/spec/features/snippets
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-14 15:06:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-14 15:06:07 +0000
commit429d1abad29d379d8bc8f5219eb72384ad485deb (patch)
tree5c8f9c96c203dbeb3e3e89f3979ce60453340f3f /spec/features/snippets
parente464f195ff5debc3e9aad0f8c4537404b92019c6 (diff)
downloadgitlab-ce-429d1abad29d379d8bc8f5219eb72384ad485deb.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/snippets')
-rw-r--r--spec/features/snippets/private_snippets_spec.rb22
-rw-r--r--spec/features/snippets/public_snippets_spec.rb2
-rw-r--r--spec/features/snippets/user_creates_snippet_spec.rb8
3 files changed, 29 insertions, 3 deletions
diff --git a/spec/features/snippets/private_snippets_spec.rb b/spec/features/snippets/private_snippets_spec.rb
new file mode 100644
index 00000000000..9df4cd01103
--- /dev/null
+++ b/spec/features/snippets/private_snippets_spec.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'Private Snippets', :js do
+ let(:user) { create(:user) }
+
+ before do
+ sign_in(user)
+ end
+
+ it 'Private Snippet renders for creator' do
+ private_snippet = create(:personal_snippet, :private, author: user)
+
+ visit snippet_path(private_snippet)
+ wait_for_requests
+
+ expect(page).to have_content(private_snippet.content)
+ expect(page).not_to have_css('.js-embed-btn')
+ expect(page).not_to have_css('.js-share-btn')
+ end
+end
diff --git a/spec/features/snippets/public_snippets_spec.rb b/spec/features/snippets/public_snippets_spec.rb
index a0db00cfc67..82edda509c2 100644
--- a/spec/features/snippets/public_snippets_spec.rb
+++ b/spec/features/snippets/public_snippets_spec.rb
@@ -10,6 +10,8 @@ describe 'Public Snippets', :js do
wait_for_requests
expect(page).to have_content(public_snippet.content)
+ expect(page).to have_css('.js-embed-btn', visible: false)
+ expect(page).to have_css('.js-share-btn', visible: false)
end
it 'Unauthenticated user should see raw public snippets' do
diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb
index 52ec5eddd5c..9a141dd463a 100644
--- a/spec/features/snippets/user_creates_snippet_spec.rb
+++ b/spec/features/snippets/user_creates_snippet_spec.rb
@@ -45,7 +45,9 @@ describe 'User creates snippet', :js do
link = find('a.no-attachment-icon img[alt="banana_sample"]')['src']
expect(link).to match(%r{/uploads/-/system/user/#{user.id}/\h{32}/banana_sample\.gif\z})
- reqs = inspect_requests { visit(link) }
+ # Adds a cache buster for checking if the image exists as Selenium is now handling the cached regquests
+ # not anymore as requests when they come straight from memory cache.
+ reqs = inspect_requests { visit("#{link}?ran=#{SecureRandom.base64(20)}") }
expect(reqs.first.status_code).to eq(200)
end
end
@@ -63,7 +65,7 @@ describe 'User creates snippet', :js do
link = find('a.no-attachment-icon img[alt="banana_sample"]')['src']
expect(link).to match(%r{/uploads/-/system/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z})
- reqs = inspect_requests { visit(link) }
+ reqs = inspect_requests { visit("#{link}?ran=#{SecureRandom.base64(20)}") }
expect(reqs.first.status_code).to eq(200)
end
@@ -88,7 +90,7 @@ describe 'User creates snippet', :js do
link = find('a.no-attachment-icon img[alt="banana_sample"]')['src']
expect(link).to match(%r{/uploads/-/system/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z})
- reqs = inspect_requests { visit(link) }
+ reqs = inspect_requests { visit("#{link}?ran=#{SecureRandom.base64(20)}") }
expect(reqs.first.status_code).to eq(200)
end