2020-09-28 14:09:40 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe 'Releases (JavaScript fixtures)' do
|
2020-09-29 05:09:49 -04:00
|
|
|
include ApiHelpers
|
2020-09-28 14:09:40 -04:00
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
2020-10-01 08:10:14 -04:00
|
|
|
let_it_be(:admin) { create(:admin, username: 'administrator', email: 'admin@example.gitlab.com') }
|
|
|
|
let_it_be(:namespace) { create(:namespace, path: 'releases-namespace') }
|
|
|
|
let_it_be(:project) { create(:project, :repository, namespace: namespace, path: 'releases-project') }
|
2020-09-28 14:09:40 -04:00
|
|
|
|
|
|
|
let_it_be(:milestone_12_3) do
|
|
|
|
create(:milestone,
|
2020-10-01 08:10:14 -04:00
|
|
|
id: 123,
|
2020-09-28 14:09:40 -04:00
|
|
|
project: project,
|
|
|
|
title: '12.3',
|
2020-09-30 14:09:52 -04:00
|
|
|
description: 'The 12.3 milestone',
|
2020-09-28 14:09:40 -04:00
|
|
|
start_date: Time.zone.parse('2018-12-10'),
|
|
|
|
due_date: Time.zone.parse('2019-01-10'))
|
|
|
|
end
|
|
|
|
|
|
|
|
let_it_be(:milestone_12_4) do
|
|
|
|
create(:milestone,
|
2020-10-01 08:10:14 -04:00
|
|
|
id: 124,
|
2020-09-28 14:09:40 -04:00
|
|
|
project: project,
|
|
|
|
title: '12.4',
|
2020-09-30 14:09:52 -04:00
|
|
|
description: 'The 12.4 milestone',
|
2020-09-28 14:09:40 -04:00
|
|
|
start_date: Time.zone.parse('2019-01-10'),
|
|
|
|
due_date: Time.zone.parse('2019-02-10'))
|
|
|
|
end
|
|
|
|
|
|
|
|
let_it_be(:open_issues_12_3) do
|
|
|
|
create_list(:issue, 2, milestone: milestone_12_3, project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
let_it_be(:closed_issues_12_3) do
|
|
|
|
create_list(:issue, 3, :closed, milestone: milestone_12_3, project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
let_it_be(:open_issues_12_4) do
|
|
|
|
create_list(:issue, 3, milestone: milestone_12_4, project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
let_it_be(:closed_issues_12_4) do
|
|
|
|
create_list(:issue, 1, :closed, milestone: milestone_12_4, project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
let_it_be(:release) do
|
|
|
|
create(:release,
|
|
|
|
milestones: [milestone_12_3, milestone_12_4],
|
|
|
|
project: project,
|
|
|
|
tag: 'v1.1',
|
|
|
|
name: 'The first release',
|
2020-10-01 08:10:14 -04:00
|
|
|
author: admin,
|
2020-09-28 14:09:40 -04:00
|
|
|
description: 'Best. Release. **Ever.** :rocket:',
|
|
|
|
created_at: Time.zone.parse('2018-12-3'),
|
|
|
|
released_at: Time.zone.parse('2018-12-10'))
|
|
|
|
end
|
|
|
|
|
2020-10-01 08:10:14 -04:00
|
|
|
let_it_be(:evidence) do
|
|
|
|
create(:evidence,
|
|
|
|
release: release,
|
|
|
|
collected_at: Time.zone.parse('2018-12-03'))
|
|
|
|
end
|
|
|
|
|
2020-09-28 14:09:40 -04:00
|
|
|
let_it_be(:other_link) do
|
|
|
|
create(:release_link,
|
2020-10-01 08:10:14 -04:00
|
|
|
id: 10,
|
2020-09-28 14:09:40 -04:00
|
|
|
release: release,
|
|
|
|
name: 'linux-amd64 binaries',
|
|
|
|
filepath: '/binaries/linux-amd64',
|
|
|
|
url: 'https://downloads.example.com/bin/gitlab-linux-amd64')
|
|
|
|
end
|
|
|
|
|
|
|
|
let_it_be(:runbook_link) do
|
|
|
|
create(:release_link,
|
2020-10-01 08:10:14 -04:00
|
|
|
id: 11,
|
2020-09-28 14:09:40 -04:00
|
|
|
release: release,
|
|
|
|
name: 'Runbook',
|
2020-09-30 14:09:52 -04:00
|
|
|
url: "#{release.project.web_url}/runbook",
|
2020-09-28 14:09:40 -04:00
|
|
|
link_type: :runbook)
|
|
|
|
end
|
|
|
|
|
2020-09-30 14:09:52 -04:00
|
|
|
let_it_be(:package_link) do
|
|
|
|
create(:release_link,
|
2020-10-01 08:10:14 -04:00
|
|
|
id: 12,
|
2020-09-30 14:09:52 -04:00
|
|
|
release: release,
|
|
|
|
name: 'Package',
|
|
|
|
url: 'https://example.com/package',
|
|
|
|
link_type: :package)
|
|
|
|
end
|
|
|
|
|
|
|
|
let_it_be(:image_link) do
|
|
|
|
create(:release_link,
|
2020-10-01 08:10:14 -04:00
|
|
|
id: 13,
|
2020-09-30 14:09:52 -04:00
|
|
|
release: release,
|
|
|
|
name: 'Image',
|
|
|
|
url: 'https://example.com/image',
|
|
|
|
link_type: :image)
|
|
|
|
end
|
|
|
|
|
2021-06-15 05:10:21 -04:00
|
|
|
let_it_be(:another_release) do
|
|
|
|
create(:release,
|
|
|
|
project: project,
|
|
|
|
tag: 'v1.2',
|
|
|
|
name: 'The second release',
|
|
|
|
author: admin,
|
|
|
|
description: 'An okay release :shrug:',
|
|
|
|
created_at: Time.zone.parse('2019-01-03'),
|
|
|
|
released_at: Time.zone.parse('2019-01-10'))
|
|
|
|
end
|
|
|
|
|
2020-09-28 14:09:40 -04:00
|
|
|
after(:all) do
|
|
|
|
remove_repository(project)
|
|
|
|
end
|
|
|
|
|
2020-09-29 05:09:49 -04:00
|
|
|
describe API::Releases, type: :request do
|
2020-09-28 14:09:40 -04:00
|
|
|
it 'api/releases/release.json' do
|
|
|
|
get api("/projects/#{project.id}/releases/#{release.tag}", admin)
|
|
|
|
|
|
|
|
expect(response).to be_successful
|
|
|
|
end
|
|
|
|
end
|
2020-09-29 05:09:49 -04:00
|
|
|
|
2020-10-15 05:08:41 -04:00
|
|
|
describe GraphQL::Query, type: :request do
|
2020-09-29 05:09:49 -04:00
|
|
|
include GraphqlHelpers
|
|
|
|
|
2021-05-11 20:10:27 -04:00
|
|
|
all_releases_query_path = 'releases/graphql/queries/all_releases.query.graphql'
|
|
|
|
one_release_query_path = 'releases/graphql/queries/one_release.query.graphql'
|
|
|
|
one_release_for_editing_query_path = 'releases/graphql/queries/one_release_for_editing.query.graphql'
|
2020-10-15 05:08:41 -04:00
|
|
|
|
|
|
|
it "graphql/#{all_releases_query_path}.json" do
|
2021-07-01 14:07:29 -04:00
|
|
|
query = get_graphql_query_as_string(all_releases_query_path)
|
2020-09-29 05:09:49 -04:00
|
|
|
|
|
|
|
post_graphql(query, current_user: admin, variables: { fullPath: project.full_path })
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
2021-06-16 14:10:35 -04:00
|
|
|
expect(graphql_data_at(:project, :releases)).to be_present
|
2020-09-29 05:09:49 -04:00
|
|
|
end
|
2020-10-15 05:08:41 -04:00
|
|
|
|
|
|
|
it "graphql/#{one_release_query_path}.json" do
|
2021-07-01 14:07:29 -04:00
|
|
|
query = get_graphql_query_as_string(one_release_query_path)
|
2021-04-26 14:09:45 -04:00
|
|
|
|
|
|
|
post_graphql(query, current_user: admin, variables: { fullPath: project.full_path, tagName: release.tag })
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
2021-06-16 14:10:35 -04:00
|
|
|
expect(graphql_data_at(:project, :release)).to be_present
|
2021-04-26 14:09:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "graphql/#{one_release_for_editing_query_path}.json" do
|
2021-07-01 14:07:29 -04:00
|
|
|
query = get_graphql_query_as_string(one_release_for_editing_query_path)
|
2020-10-15 05:08:41 -04:00
|
|
|
|
|
|
|
post_graphql(query, current_user: admin, variables: { fullPath: project.full_path, tagName: release.tag })
|
|
|
|
|
|
|
|
expect_graphql_errors_to_be_empty
|
2021-06-16 14:10:35 -04:00
|
|
|
expect(graphql_data_at(:project, :release)).to be_present
|
2020-10-15 05:08:41 -04:00
|
|
|
end
|
2020-09-29 05:09:49 -04:00
|
|
|
end
|
2020-09-28 14:09:40 -04:00
|
|
|
end
|