summaryrefslogtreecommitdiff
path: root/spec/migrations/add_pages_access_level_to_project_feature_spec.rb
blob: 69f1e3ba3d038502139a75f9f8d0e151945b3dcb (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
# frozen_string_literal: true

require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180423204600_add_pages_access_level_to_project_feature.rb')

describe AddPagesAccessLevelToProjectFeature do
  let(:namespaces) { table(:namespaces) }
  let(:projects) { table(:projects) }
  let(:features) { table(:project_features) }
  let!(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab') }
  let!(:first_project) { projects.create(name: 'gitlab1', path: 'gitlab1', namespace_id: namespace.id) }
  let!(:first_project_features) { features.create(project_id: first_project.id) }
  let!(:second_project) { projects.create(name: 'gitlab2', path: 'gitlab2', namespace_id: namespace.id) }
  let!(:second_project_features) { features.create(project_id: second_project.id) }

  it 'correctly migrate pages for old projects to be public' do
    migrate!

    # For old projects pages should be public
    expect(first_project_features.reload.pages_access_level).to eq ProjectFeature::PUBLIC
    expect(second_project_features.reload.pages_access_level).to eq ProjectFeature::PUBLIC
  end

  it 'after migration pages are enabled as default' do
    migrate!

    # For new project default is enabled
    third_project = projects.create(name: 'gitlab3', path: 'gitlab3', namespace_id: namespace.id)
    third_project_features = features.create(project_id: third_project.id)
    expect(third_project_features.reload.pages_access_level).to eq ProjectFeature::ENABLED
  end
end