diff options
Diffstat (limited to 'spec/presenters/snippet_blob_presenter_spec.rb')
-rw-r--r-- | spec/presenters/snippet_blob_presenter_spec.rb | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/spec/presenters/snippet_blob_presenter_spec.rb b/spec/presenters/snippet_blob_presenter_spec.rb index eb7621cc591..7464c0ac15b 100644 --- a/spec/presenters/snippet_blob_presenter_spec.rb +++ b/spec/presenters/snippet_blob_presenter_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe SnippetBlobPresenter do +RSpec.describe SnippetBlobPresenter do describe '#rich_data' do before do allow_next_instance_of(described_class) do |instance| @@ -109,22 +109,38 @@ describe SnippetBlobPresenter do end describe '#raw_path' do - subject { described_class.new(snippet.blob).raw_path } + let_it_be(:project) { create(:project) } + let_it_be(:user) { create(:user) } + let_it_be(:personal_snippet) { create(:personal_snippet, :repository, author: user) } + let_it_be(:project_snippet) { create(:project_snippet, :repository, project: project, author: user) } - context 'with ProjectSnippet' do - let!(:project) { create(:project) } - let(:snippet) { create(:project_snippet, project: project) } + before do + project.add_developer(user) + end + + subject { described_class.new(snippet.blobs.first, current_user: user).raw_path } - it 'returns the raw path' do - expect(subject).to eq "/#{snippet.project.full_path}/snippets/#{snippet.id}/raw" + it_behaves_like 'snippet blob raw path' + + context 'with snippet_multiple_files feature disabled' do + before do + stub_feature_flags(snippet_multiple_files: false) end - end - context 'with PersonalSnippet' do - let(:snippet) { create(:personal_snippet) } + context 'with ProjectSnippet' do + let(:snippet) { project_snippet } - it 'returns the raw path' do - expect(subject).to eq "/snippets/#{snippet.id}/raw" + it 'returns the raw path' do + expect(subject).to eq "/#{snippet.project.full_path}/snippets/#{snippet.id}/raw" + end + end + + context 'with PersonalSnippet' do + let(:snippet) { personal_snippet } + + it 'returns the raw path' do + expect(subject).to eq "/snippets/#{snippet.id}/raw" + end end end end |