Commit 9f23f82b authored by Shinya Maeda's avatar Shinya Maeda

Merge branch...

Merge branch '353309-group-level-protected-environments-don-t-take-inherited-membership-into-account' into 'master'

Resolve "Group-level PE don't take inherited membership into account"

See merge request gitlab-org/gitlab!82415
parents cb6740ab decab235
......@@ -22,7 +22,7 @@ class ProtectedEnvironment::DeployAccessLevel < ApplicationRecord
return false unless user
return true if user.admin?
return user.id == user_id if user_type?
return group.users.exists?(user.id) if group_type?
return group.member?(user) if group_type?
protected_environment.container_access_level(user) >= access_level
end
......
......@@ -70,6 +70,19 @@ RSpec.describe ProtectedEnvironment::DeployAccessLevel do
it { is_expected.to be_truthy }
end
context 'when there is an inherited member of a group' do
let_it_be(:parent_group) { create(:group) }
let_it_be(:child_group) { create(:group, parent: parent_group, projects: [project])}
let(:deploy_access_level) { create(:protected_environment_deploy_access_level, protected_environment: protected_environment, group: child_group) }
before do
parent_group.add_reporter(user)
end
it { is_expected.to be_truthy }
end
context 'when no permissions have been given to a group' do
let(:deploy_access_level) { create(:protected_environment_deploy_access_level, protected_environment: protected_environment) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment