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

license_detection_spec.rb « repository « 3_create « browser_ui « features « specs « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 24ef490b3de027dc3407212a24f4907230d65f3a (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
# frozen_string_literal: true

module QA
  RSpec.describe 'Create' do
    describe 'Repository License Detection', product_group: :source_code do
      after do
        project.remove_via_api!
      end

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

      shared_examples 'project license detection' do
        it 'displays the name of the license on the repository' do
          license_path = Runtime::Path.fixture('software_licenses', license_file_name)
          Resource::Repository::Commit.fabricate_via_api! do |commit|
            commit.project = project
            commit.add_files([{ file_path: 'LICENSE', content: File.read(license_path) }])
          end

          project.visit!

          Page::Project::Show.perform do |project|
            Support::Waiter.wait_until(reload_page: project, message: 'Waiting for licence') do
              project.has_license?(rendered_license_name)
            end
          end
        end
      end

      context 'on a project with a commonly used LICENSE',
        testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/366842' do
        it_behaves_like 'project license detection' do
          let(:license_file_name) { 'bsd-3-clause' }
          let(:rendered_license_name) { 'BSD 3-Clause "New" or "Revised" License' }
        end
      end

      context 'on a project with an unrecognized LICENSE',
        testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/366843' do
        it_behaves_like 'project license detection' do
          let(:license_file_name) { 'other' }
          let(:rendered_license_name) { 'LICENSE' }
        end
      end
    end
  end
end