2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'User views releases', :js do
|
2020-04-22 19:07:51 +05:30
|
|
|
let_it_be(:project) { create(:project, :repository, :private) }
|
|
|
|
let_it_be(:release) { create(:release, project: project, name: 'The first release' ) }
|
|
|
|
let_it_be(:maintainer) { create(:user) }
|
|
|
|
let_it_be(:guest) { create(:user) }
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
before do
|
2020-04-22 19:07:51 +05:30
|
|
|
project.add_maintainer(maintainer)
|
|
|
|
project.add_guest(guest)
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
context('when the user is a maintainer') do
|
|
|
|
before do
|
|
|
|
gitlab_sign_in(maintainer)
|
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
it 'sees the release' do
|
2019-03-02 22:35:43 +05:30
|
|
|
visit project_releases_path(project)
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
expect(page).to have_content(release.name)
|
|
|
|
expect(page).to have_content(release.tag)
|
|
|
|
expect(page).not_to have_content('Upcoming Release')
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
shared_examples 'asset link tests' do
|
|
|
|
context 'when there is a link as an asset' do
|
|
|
|
let!(:release_link) { create(:release_link, release: release, url: url ) }
|
2020-04-22 19:07:51 +05:30
|
|
|
let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" }
|
2020-06-23 00:09:42 +05:30
|
|
|
let(:direct_asset_link) { Gitlab::Routing.url_helpers.project_release_url(project, release) << release_link.filepath }
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
it 'sees the link' do
|
|
|
|
visit project_releases_path(project)
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
page.within('.js-assets-list') do
|
|
|
|
expect(page).to have_link release_link.name, href: direct_asset_link
|
2020-06-23 00:09:42 +05:30
|
|
|
expect(page).not_to have_css('[data-testid="external-link-indicator"]')
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
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" }
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
it 'sees the link' do
|
|
|
|
visit project_releases_path(project)
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
page.within('.js-assets-list') do
|
|
|
|
expect(page).to have_link release_link.name, href: direct_asset_link
|
|
|
|
expect(page).not_to have_css('[data-testid="external-link-indicator"]')
|
|
|
|
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_css('[data-testid="external-link-indicator"]')
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
context 'when the release_asset_link_type feature flag is enabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(release_asset_link_type: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'asset link tests'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the release_asset_link_type feature flag is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(release_asset_link_type: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'asset link tests'
|
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
context 'with an upcoming release' do
|
|
|
|
let(:tomorrow) { Time.zone.now + 1.day }
|
|
|
|
let!(:release) { create(:release, project: project, released_at: tomorrow ) }
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
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
|
2020-06-23 00:09:42 +05:30
|
|
|
release = create :release, project: project, tag: 'debian/2.4.0-1'
|
2020-04-22 19:07:51 +05:30
|
|
|
visit project_releases_path(project)
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
expect(page).to have_content(release.name)
|
|
|
|
expect(page).to have_content(release.tag)
|
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|
2020-01-12 00:16:45 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
context('when the user is a guest') do
|
|
|
|
before do
|
|
|
|
gitlab_sign_in(guest)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders release info except for Git-related data' do
|
2020-01-12 00:16:45 +05:30
|
|
|
visit project_releases_path(project)
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
within('.release-block') do
|
|
|
|
expect(page).to have_content(release.description)
|
|
|
|
|
|
|
|
# The following properties (sometimes) include Git info,
|
|
|
|
# so they are not rendered for Guest users
|
|
|
|
expect(page).not_to have_content(release.name)
|
|
|
|
expect(page).not_to have_content(release.tag)
|
|
|
|
expect(page).not_to have_content(release.commit.short_id)
|
|
|
|
end
|
2020-01-12 00:16:45 +05:30
|
|
|
end
|
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|