diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-06 12:06:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-06 12:06:13 +0300 |
commit | 7c21abab2ad1c87375b3172aaa92b1f9fc1175e4 (patch) | |
tree | 700416b30f6e55df65cc82bdcb55e8c51b608ed0 /spec | |
parent | b83314141e6420ca252099665beb520fa2f7da7c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/policies/group_policy_spec.rb | 43 | ||||
-rw-r--r-- | spec/spec_helper.rb | 2 | ||||
-rw-r--r-- | spec/support/shared_contexts/policies/group_policy_shared_context.rb | 16 |
3 files changed, 34 insertions, 27 deletions
diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb index d697840601f..02bcc716bee 100644 --- a/spec/policies/group_policy_spec.rb +++ b/spec/policies/group_policy_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe GroupPolicy do include_context 'GroupPolicy context' - context 'with no user' do + context 'public group with no user' do let(:group) { create(:group, :public) } let(:current_user) { nil } @@ -33,7 +33,6 @@ describe GroupPolicy do context 'with foreign user and public project' do let(:project) { create(:project, :public) } - let(:user) { create(:user) } let(:current_user) { create(:user) } before do @@ -105,8 +104,8 @@ describe GroupPolicy do let(:current_user) { maintainer } context 'with subgroup_creation level set to maintainer' do - let(:group) do - create(:group, :private, subgroup_creation_level: ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS) + before_all do + group.update(subgroup_creation_level: ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS) end it 'allows every maintainer permission plus creating subgroups' do @@ -164,11 +163,11 @@ describe GroupPolicy do end describe 'private nested group use the highest access level from the group and inherited permissions' do - let(:nested_group) do + let_it_be(:nested_group) do create(:group, :private, :owner_subgroup_creation_only, parent: group) end - before do + before_all do nested_group.add_guest(guest) nested_group.add_guest(reporter) nested_group.add_guest(developer) @@ -268,6 +267,10 @@ describe GroupPolicy do context 'when the group share_with_group_lock is enabled' do let(:group) { create(:group, share_with_group_lock: true, parent: parent) } + before do + group.add_owner(owner) + end + context 'when the parent group share_with_group_lock is enabled' do context 'when the group has a grandparent' do let(:parent) { create(:group, share_with_group_lock: true, parent: grandparent) } @@ -353,7 +356,9 @@ describe GroupPolicy do context "create_projects" do context 'when group has no project creation level set' do - let(:group) { create(:group, project_creation_level: nil) } + before_all do + group.update(project_creation_level: nil) + end context 'reporter' do let(:current_user) { reporter } @@ -381,7 +386,9 @@ describe GroupPolicy do end context 'when group has project creation level set to no one' do - let(:group) { create(:group, project_creation_level: ::Gitlab::Access::NO_ONE_PROJECT_ACCESS) } + before_all do + group.update(project_creation_level: ::Gitlab::Access::NO_ONE_PROJECT_ACCESS) + end context 'reporter' do let(:current_user) { reporter } @@ -409,7 +416,9 @@ describe GroupPolicy do end context 'when group has project creation level set to maintainer only' do - let(:group) { create(:group, project_creation_level: ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS) } + before_all do + group.update(project_creation_level: ::Gitlab::Access::MAINTAINER_PROJECT_ACCESS) + end context 'reporter' do let(:current_user) { reporter } @@ -437,7 +446,9 @@ describe GroupPolicy do end context 'when group has project creation level set to developers + maintainer' do - let(:group) { create(:group, project_creation_level: ::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS) } + before_all do + group.update(project_creation_level: ::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS) + end context 'reporter' do let(:current_user) { reporter } @@ -467,10 +478,8 @@ describe GroupPolicy do context "create_subgroup" do context 'when group has subgroup creation level set to owner' do - let(:group) do - create( - :group, - subgroup_creation_level: ::Gitlab::Access::OWNER_SUBGROUP_ACCESS) + before_all do + group.update(subgroup_creation_level: ::Gitlab::Access::OWNER_SUBGROUP_ACCESS) end context 'reporter' do @@ -499,10 +508,8 @@ describe GroupPolicy do end context 'when group has subgroup creation level set to maintainer' do - let(:group) do - create( - :group, - subgroup_creation_level: ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS) + before_all do + group.update(subgroup_creation_level: ::Gitlab::Access::MAINTAINER_SUBGROUP_ACCESS) end context 'reporter' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d6c326764d1..2142a43177a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,7 +10,7 @@ require 'rspec/rails' require 'shoulda/matchers' require 'rspec/retry' require 'rspec-parameterized' -require "test_prof/recipes/rspec/let_it_be" +require 'test_prof/recipes/rspec/let_it_be' rspec_profiling_is_configured = ENV['RSPEC_PROFILING_POSTGRES_URL'].present? || diff --git a/spec/support/shared_contexts/policies/group_policy_shared_context.rb b/spec/support/shared_contexts/policies/group_policy_shared_context.rb index 2f3a1b911e4..c503197a773 100644 --- a/spec/support/shared_contexts/policies/group_policy_shared_context.rb +++ b/spec/support/shared_contexts/policies/group_policy_shared_context.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true RSpec.shared_context 'GroupPolicy context' do - let(:guest) { create(:user) } - let(:reporter) { create(:user) } - let(:developer) { create(:user) } - let(:maintainer) { create(:user) } - let(:owner) { create(:user) } - let(:admin) { create(:admin) } - let(:group) { create(:group, :private, :owner_subgroup_creation_only) } + let_it_be(:guest) { create(:user) } + let_it_be(:reporter) { create(:user) } + let_it_be(:developer) { create(:user) } + let_it_be(:maintainer) { create(:user) } + let_it_be(:owner) { create(:user) } + let_it_be(:admin) { create(:admin) } + let_it_be(:group, refind: true) { create(:group, :private, :owner_subgroup_creation_only) } let(:guest_permissions) do %i[ @@ -37,7 +37,7 @@ RSpec.shared_context 'GroupPolicy context' do ].compact end - before do + before_all do group.add_guest(guest) group.add_reporter(reporter) group.add_developer(developer) |