Merge branch 'sh-guard-against-orphaned-project-feature' into 'master'
Guard against deleted project feature entry Closes #66482 See merge request gitlab-org/gitlab-ce!32187
This commit is contained in:
commit
452b5d605c
|
@ -502,6 +502,8 @@ class ProjectPolicy < BasePolicy
|
||||||
end
|
end
|
||||||
|
|
||||||
def feature_available?(feature)
|
def feature_available?(feature)
|
||||||
|
return false unless project.project_feature
|
||||||
|
|
||||||
case project.project_feature.access_level(feature)
|
case project.project_feature.access_level(feature)
|
||||||
when ProjectFeature::DISABLED
|
when ProjectFeature::DISABLED
|
||||||
false
|
false
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Guard against deleted project feature entry in project permissions
|
||||||
|
merge_request: 32187
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -94,6 +94,19 @@ describe ProjectPolicy do
|
||||||
permissions.each { |p| is_expected.not_to be_allowed(p) }
|
permissions.each { |p| is_expected.not_to be_allowed(p) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with no project feature' do
|
||||||
|
subject { described_class.new(owner, project) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
project.project_feature.destroy
|
||||||
|
project.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns false' do
|
||||||
|
is_expected.to be_disallowed(:read_build)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'does not include the read_issue permission when the issue author is not a member of the private project' do
|
it 'does not include the read_issue permission when the issue author is not a member of the private project' do
|
||||||
project = create(:project, :private)
|
project = create(:project, :private)
|
||||||
issue = create(:issue, project: project, author: create(:user))
|
issue = create(:issue, project: project, author: create(:user))
|
||||||
|
|
Loading…
Reference in New Issue