summaryrefslogtreecommitdiff
path: root/spec/controllers/concerns/lfs_request_spec.rb
blob: cb8c0b8f71c376b87e91c08e19d06061ffd9a7a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true

require 'spec_helper'

describe LfsRequest do
  include ProjectForksHelper

  controller(Projects::GitHttpClientController) do
    # `described_class` is not available in this context
    include LfsRequest # rubocop:disable RSpec/DescribedClass

    def show
      storage_project

      head :ok
    end

    def project
      @project ||= Project.find(params[:id])
    end

    def download_request?
      true
    end

    def ci?
      false
    end
  end

  let(:project) { create(:project, :public) }

  before do
    stub_lfs_setting(enabled: true)
  end

  describe '#storage_project' do
    it 'assigns the project as storage project' do
      get :show, params: { id: project.id }

      expect(assigns(:storage_project)).to eq(project)
    end

    it 'assigns the source of a forked project' do
      forked_project = fork_project(project)

      get :show, params: { id: forked_project.id }

      expect(assigns(:storage_project)).to eq(project)
    end
  end
end