summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 12:09:18 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-15 12:09:18 +0000
commitb7c735c8ac11b8182807070fc6f84f2606e15427 (patch)
treee74b4d25abb8bbf23546f001dd94515e2840a3a3 /spec/helpers
parent221b529789f4090341a825695aeb49b8df6dd11d (diff)
downloadgitlab-ce-b7c735c8ac11b8182807070fc6f84f2606e15427.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/snippets_helper_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/helpers/snippets_helper_spec.rb b/spec/helpers/snippets_helper_spec.rb
index 6fdf4f5cfb4..b5b431b5818 100644
--- a/spec/helpers/snippets_helper_spec.rb
+++ b/spec/helpers/snippets_helper_spec.rb
@@ -151,4 +151,35 @@ describe SnippetsHelper do
"<input type=\"text\" readonly=\"readonly\" class=\"js-snippet-url-area snippet-embed-input form-control\" data-url=\"#{url}\" value=\"<script src=&quot;#{url}.js&quot;></script>\" autocomplete=\"off\"></input>"
end
end
+
+ describe '#snippet_file_name' do
+ subject { helper.snippet_file_name(snippet) }
+
+ where(:snippet_type, :flag_enabled, :trait, :filename) do
+ [
+ [:personal_snippet, false, nil, 'foo.txt'],
+ [:personal_snippet, true, nil, 'foo.txt'],
+ [:personal_snippet, false, :repository, 'foo.txt'],
+ [:personal_snippet, true, :repository, '.gitattributes'],
+
+ [:project_snippet, false, nil, 'foo.txt'],
+ [:project_snippet, true, nil, 'foo.txt'],
+ [:project_snippet, false, :repository, 'foo.txt'],
+ [:project_snippet, true, :repository, '.gitattributes']
+ ]
+ end
+
+ with_them do
+ let(:snippet) { create(snippet_type, trait, file_name: 'foo.txt') }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(snippet.author)
+ stub_feature_flags(version_snippets: flag_enabled)
+ end
+
+ it 'returns the correct filename' do
+ expect(subject).to eq filename
+ end
+ end
+ end
end