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

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

require 'spec_helper'

require_migration!

RSpec.describe PopulateReleasesAccessLevelFromRepository, :migration do
  let(:projects) { table(:projects) }
  let(:groups) { table(:namespaces) }
  let(:project_features) { table(:project_features) }

  let(:group) { groups.create!(name: 'test-group', path: 'test-group') }
  let(:project) { projects.create!(namespace_id: group.id, project_namespace_id: group.id) }
  let(:project_feature) do
    project_features.create!(project_id: project.id, pages_access_level: 20, **project_feature_attributes)
  end

  # repository_access_level and releases_access_level default to ENABLED
  describe '#up' do
    context 'when releases_access_level is greater than repository_access_level' do
      let(:project_feature_attributes) { { repository_access_level: ProjectFeature::PRIVATE } }

      it 'reduces releases_access_level to match repository_access_level' do
        expect { migrate! }.to change { project_feature.reload.releases_access_level }
                           .from(ProjectFeature::ENABLED)
                           .to(ProjectFeature::PRIVATE)
      end
    end

    context 'when releases_access_level is less than repository_access_level' do
      let(:project_feature_attributes) { { releases_access_level: ProjectFeature::DISABLED } }

      it 'does not change releases_access_level' do
        expect { migrate! }.not_to change { project_feature.reload.releases_access_level }
                           .from(ProjectFeature::DISABLED)
      end
    end
  end
end