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

user_views_releases_spec.rb « releases « projects « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a4ba81ffeb96ac502cda9ae104ff10868e2fede4 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# frozen_string_literal: true

require 'spec_helper'

describe 'User views releases', :js do
  let!(:project) { create(:project, :repository) }
  let!(:release) { create(:release, project: project ) }
  let!(:user) { create(:user) }

  before do
    project.add_maintainer(user)

    gitlab_sign_in(user)
  end

  it 'sees the release' do
    visit project_releases_path(project)

    expect(page).to have_content(release.name)
    expect(page).to have_content(release.tag)
    expect(page).not_to have_content('Upcoming Release')
  end

  context 'when there is a link as an asset' do
    let!(:release_link) { create(:release_link, release: release, url: url ) }
    let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" }
    let(:direct_asset_link) { Gitlab::Routing.url_helpers.project_release_url(project, release) << release_link.filepath }

    it 'sees the link' do
      visit project_releases_path(project)

      page.within('.js-assets-list') do
        expect(page).to have_link release_link.name, href: direct_asset_link
        expect(page).not_to have_content('(external source)')
      end
    end

    context 'when there is a link redirect' do
      let!(:release_link) { create(:release_link, release: release, name: 'linux-amd64 binaries', filepath: '/binaries/linux-amd64', url: url) }
      let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" }

      it 'sees the link' do
        visit project_releases_path(project)

        page.within('.js-assets-list') do
          expect(page).to have_link release_link.name, href: direct_asset_link
          expect(page).not_to have_content('(external source)')
        end
      end
    end

    context 'when url points to external resource' do
      let(:url) { 'http://google.com/download' }

      it 'sees that the link is external resource' do
        visit project_releases_path(project)

        page.within('.js-assets-list') do
          expect(page).to have_content('(external source)')
        end
      end
    end
  end

  context 'with an upcoming release' do
    let(:tomorrow) { Time.zone.now + 1.day }
    let!(:release) { create(:release, project: project, released_at: tomorrow ) }

    it 'sees the upcoming tag' do
      visit project_releases_path(project)

      expect(page).to have_content('Upcoming Release')
    end
  end

  context 'with a tag containing a slash' do
    it 'sees the release' do
      release = create :release, :with_evidence, project: project, tag: 'debian/2.4.0-1'
      visit project_releases_path(project)

      expect(page).to have_content(release.name)
      expect(page).to have_content(release.tag)
    end
  end
end