3126e89eb8
This commit has two migrations: 1. The first prunes duplicate rows in the project_features table and leaves the row with the highest ID. Since the behavior was indeterministic before and depended on which row the database decided to use, this change at least makes the permissions consistent. For example, in some cases, the Wiki may have been disabled but enabled in another entry. 2. The second adds a non-null constraint on the project_features.project_id column. Closes #37882 Fixes a significant part of gitlab-com/migration#408. We found that we were overcounting Wikis because of these duplicates. On GitLab.com, there are 56 rows with duplicate entries by project_id, and 16,661 rows with NULL project_id values.
45 lines
1.5 KiB
Ruby
45 lines
1.5 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Guest do
|
|
set(:public_project) { create(:project, :public) }
|
|
set(:private_project) { create(:project, :private) }
|
|
set(:internal_project) { create(:project, :internal) }
|
|
|
|
describe '.can_pull?' do
|
|
context 'when project is private' do
|
|
it 'does not allow to pull the repo' do
|
|
expect(described_class.can?(:download_code, private_project)).to eq(false)
|
|
end
|
|
end
|
|
|
|
context 'when project is internal' do
|
|
it 'does not allow to pull the repo' do
|
|
expect(described_class.can?(:download_code, internal_project)).to eq(false)
|
|
end
|
|
end
|
|
|
|
context 'when project is public' do
|
|
context 'when repository is disabled' do
|
|
it 'does not allow to pull the repo' do
|
|
public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED)
|
|
|
|
expect(described_class.can?(:download_code, public_project)).to eq(false)
|
|
end
|
|
end
|
|
|
|
context 'when repository is accessible only by team members' do
|
|
it 'does not allow to pull the repo' do
|
|
public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::PRIVATE)
|
|
|
|
expect(described_class.can?(:download_code, public_project)).to eq(false)
|
|
end
|
|
end
|
|
|
|
context 'when repository is enabled' do
|
|
it 'allows to pull the repo' do
|
|
expect(described_class.can?(:download_code, public_project)).to eq(true)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|