Welcome to mirror list, hosted at ThFree Co, Russian Federation.

link_presenter_spec.rb « releases « presenters « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e52c68ffb3894f38f9b0ac1ba7f7beba4e838f6c (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Releases::LinkPresenter do
  describe '#direct_asset_url' do
    let_it_be(:release) { create(:release) }

    let(:link) { build(:release_link, release: release, url: url, filepath: filepath) }
    let(:url) { 'https://google.com/-/jobs/140463678/artifacts/download' }
    let(:presenter) { described_class.new(link) }

    subject { presenter.direct_asset_url }

    context 'when filepath is provided' do
      let(:filepath) { '/bin/bigfile.exe' }
      let(:expected_url) do
        "http://localhost/#{release.project.namespace.path}/#{release.project.name}" \
        "/-/releases/#{release.tag}/downloads/bin/bigfile.exe"
      end

      it { is_expected.to eq(expected_url) }
    end

    context 'when filepath is not provided' do
      let(:filepath) { nil }

      it { is_expected.to eq(url) }
    end
  end
end