1# frozen_string_literal: true
2
3require 'spec_helper'
4
5RSpec.shared_examples 'snippet blob raw path' do
6  let(:blob) { snippet.blobs.first }
7  let(:ref)  { blob.repository.root_ref }
8
9  context 'for PersonalSnippets' do
10    let(:snippet) { personal_snippet }
11
12    it 'returns the raw personal snippet blob path' do
13      expect(subject).to eq("/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}")
14    end
15  end
16
17  context 'for ProjectSnippets' do
18    let(:snippet) { project_snippet }
19
20    it 'returns the raw project snippet blob path' do
21      expect(subject).to eq("/#{snippet.project.full_path}/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}")
22    end
23  end
24end
25
26RSpec.shared_examples 'snippet blob raw url' do
27  let(:blob) { snippet.blobs.first }
28  let(:ref)  { blob.repository.root_ref }
29
30  context 'for PersonalSnippets' do
31    let(:snippet) { personal_snippet }
32
33    it 'returns the raw personal snippet blob url' do
34      expect(subject).to eq("http://test.host/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}")
35    end
36  end
37
38  context 'for ProjectSnippets' do
39    let(:snippet) { project_snippet }
40
41    it 'returns the raw project snippet blob url' do
42      expect(subject).to eq("http://test.host/#{snippet.project.full_path}/-/snippets/#{snippet.id}/raw/#{ref}/#{blob.path}")
43    end
44  end
45end
46