diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/helpers/snippets_helper_spec.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/helpers/snippets_helper_spec.rb')
-rw-r--r-- | spec/helpers/snippets_helper_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/helpers/snippets_helper_spec.rb b/spec/helpers/snippets_helper_spec.rb index 913be164a00..37520affc5a 100644 --- a/spec/helpers/snippets_helper_spec.rb +++ b/spec/helpers/snippets_helper_spec.rb @@ -64,6 +64,33 @@ RSpec.describe SnippetsHelper do end end + describe '#embedded_snippet_copy_button' do + let(:blob) { snippet.blobs.first } + let(:ref) { blob.repository.root_ref } + + subject { embedded_copy_snippet_button(blob) } + + context 'for Personal Snippets' do + let(:snippet) { public_personal_snippet } + + it 'returns copy button of embedded snippets' do + expect(subject).to eq(copy_button("#{blob.id}")) + end + end + + context 'for Project Snippets' do + let(:snippet) { public_project_snippet } + + it 'returns copy button of embedded snippets' do + expect(subject).to eq(copy_button("#{blob.id}")) + end + end + + def copy_button(blob_id) + "<button class=\"gl-button btn btn-default copy-to-clipboard-btn\" title=\"Copy snippet contents\" onclick=\"copyToClipboard('.blob-content[data-blob-id="#{blob_id}"] > pre')\">#{external_snippet_icon('copy-to-clipboard')}</button>" + end + end + describe '#snippet_badge' do let(:snippet) { build(:personal_snippet, visibility) } |