diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/services/todos | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) | |
download | gitlab-ce-48aff82709769b098321c738f3444b9bdaa694c6.tar.gz |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/services/todos')
-rw-r--r-- | spec/services/todos/destroy/entity_leave_service_spec.rb | 164 |
1 files changed, 74 insertions, 90 deletions
diff --git a/spec/services/todos/destroy/entity_leave_service_spec.rb b/spec/services/todos/destroy/entity_leave_service_spec.rb index 921037bd5db..4126eb88b0b 100644 --- a/spec/services/todos/destroy/entity_leave_service_spec.rb +++ b/spec/services/todos/destroy/entity_leave_service_spec.rb @@ -19,20 +19,14 @@ RSpec.describe Todos::Destroy::EntityLeaveService do let!(:todo_issue_c_user) { create(:todo, user: user, target: issue_c, project: project) } let!(:todo_issue_c_user2) { create(:todo, user: user2, target: issue_c, project: project) } - shared_examples 'using different access permissions' do |access_table| - using RSpec::Parameterized::TableSyntax - - where(:group_access, :project_access, :c_todos, :mr_todos, :method, &access_table) - - with_them do - before do - set_access(project, user, project_access) if project_access - set_access(group, user, group_access) if group_access - end + shared_examples 'using different access permissions' do + before do + set_access(project, user, project_access) if project_access + set_access(group, user, group_access) if group_access + end - it "#{params[:method].to_s.humanize(capitalize: false)}" do - send(method) - end + it "#{params[:method].to_s.humanize(capitalize: false)}" do + send(method_name) end end @@ -84,22 +78,20 @@ RSpec.describe Todos::Destroy::EntityLeaveService do end context 'access permissions' do - # rubocop:disable RSpec/LeakyConstantDeclaration - PRIVATE_PROJECT_PRIVATE_GROUP_ACCESS_TABLE = - lambda do |_| - [ - # :group_access, :project_access, :c_todos, :mr_todos, :method - [nil, :reporter, :keep, :keep, :does_not_remove_any_todos], - [nil, :guest, :delete, :delete, :removes_confidential_issues_and_merge_request_todos], - [:reporter, nil, :keep, :keep, :does_not_remove_any_todos], - [:guest, nil, :delete, :delete, :removes_confidential_issues_and_merge_request_todos], - [:guest, :reporter, :keep, :keep, :does_not_remove_any_todos], - [:guest, :guest, :delete, :delete, :removes_confidential_issues_and_merge_request_todos] - ] - end - # rubocop:enable RSpec/LeakyConstantDeclaration + where(:group_access, :project_access, :method_name) do + [ + [nil, :reporter, :does_not_remove_any_todos], + [nil, :guest, :removes_confidential_issues_and_merge_request_todos], + [:reporter, nil, :does_not_remove_any_todos], + [:guest, nil, :removes_confidential_issues_and_merge_request_todos], + [:guest, :reporter, :does_not_remove_any_todos], + [:guest, :guest, :removes_confidential_issues_and_merge_request_todos] + ] + end - it_behaves_like 'using different access permissions', PRIVATE_PROJECT_PRIVATE_GROUP_ACCESS_TABLE + with_them do + it_behaves_like 'using different access permissions' + end end end @@ -117,22 +109,20 @@ RSpec.describe Todos::Destroy::EntityLeaveService do end context 'access permissions' do - # rubocop:disable RSpec/LeakyConstantDeclaration - PRIVATE_PROJECT_INTERNAL_GROUP_ACCESS_TABLE = - lambda do |_| - [ - # :group_access, :project_access, :c_todos, :mr_todos, :method - [nil, :reporter, :keep, :keep, :does_not_remove_any_todos], - [nil, :guest, :delete, :delete, :removes_confidential_issues_and_merge_request_todos], - [:reporter, nil, :keep, :keep, :does_not_remove_any_todos], - [:guest, nil, :delete, :delete, :removes_confidential_issues_and_merge_request_todos], - [:guest, :reporter, :keep, :keep, :does_not_remove_any_todos], - [:guest, :guest, :delete, :delete, :removes_confidential_issues_and_merge_request_todos] - ] - end - # rubocop:enable RSpec/LeakyConstantDeclaration + where(:group_access, :project_access, :method_name) do + [ + [nil, :reporter, :does_not_remove_any_todos], + [nil, :guest, :removes_confidential_issues_and_merge_request_todos], + [:reporter, nil, :does_not_remove_any_todos], + [:guest, nil, :removes_confidential_issues_and_merge_request_todos], + [:guest, :reporter, :does_not_remove_any_todos], + [:guest, :guest, :removes_confidential_issues_and_merge_request_todos] + ] + end - it_behaves_like 'using different access permissions', PRIVATE_PROJECT_INTERNAL_GROUP_ACCESS_TABLE + with_them do + it_behaves_like 'using different access permissions' + end end end @@ -172,22 +162,20 @@ RSpec.describe Todos::Destroy::EntityLeaveService do end context 'access permissions' do - # rubocop:disable RSpec/LeakyConstantDeclaration - INTERNAL_PROJECT_INTERNAL_GROUP_ACCESS_TABLE = - lambda do |_| - [ - # :group_access, :project_access, :c_todos, :mr_todos, :method - [nil, :reporter, :keep, :keep, :does_not_remove_any_todos], - [nil, :guest, :delete, :keep, :removes_only_confidential_issues_todos], - [:reporter, nil, :keep, :keep, :does_not_remove_any_todos], - [:guest, nil, :delete, :keep, :removes_only_confidential_issues_todos], - [:guest, :reporter, :keep, :keep, :does_not_remove_any_todos], - [:guest, :guest, :delete, :keep, :removes_only_confidential_issues_todos] - ] - end - # rubocop:enable RSpec/LeakyConstantDeclaration - - it_behaves_like 'using different access permissions', INTERNAL_PROJECT_INTERNAL_GROUP_ACCESS_TABLE + where(:group_access, :project_access, :method_name) do + [ + [nil, :reporter, :does_not_remove_any_todos], + [nil, :guest, :removes_only_confidential_issues_todos], + [:reporter, nil, :does_not_remove_any_todos], + [:guest, nil, :removes_only_confidential_issues_todos], + [:guest, :reporter, :does_not_remove_any_todos], + [:guest, :guest, :removes_only_confidential_issues_todos] + ] + end + + with_them do + it_behaves_like 'using different access permissions' + end end end @@ -219,22 +207,20 @@ RSpec.describe Todos::Destroy::EntityLeaveService do end context 'access permissions' do - # rubocop:disable RSpec/LeakyConstantDeclaration - PRIVATE_GROUP_PRIVATE_PROJECT_ACCESS_TABLE = - lambda do |_| - [ - # :group_access, :project_access, :c_todos, :mr_todos, :method - [nil, :reporter, :keep, :keep, :does_not_remove_any_todos], - [nil, :guest, :delete, :delete, :removes_confidential_issues_and_merge_request_todos], - [:reporter, nil, :keep, :keep, :does_not_remove_any_todos], - [:guest, nil, :delete, :delete, :removes_confidential_issues_and_merge_request_todos], - [:guest, :reporter, :keep, :keep, :does_not_remove_any_todos], - [:guest, :guest, :delete, :delete, :removes_confidential_issues_and_merge_request_todos] - ] - end - # rubocop:enable RSpec/LeakyConstantDeclaration + where(:group_access, :project_access, :method_name) do + [ + [nil, :reporter, :does_not_remove_any_todos], + [nil, :guest, :removes_confidential_issues_and_merge_request_todos], + [:reporter, nil, :does_not_remove_any_todos], + [:guest, nil, :removes_confidential_issues_and_merge_request_todos], + [:guest, :reporter, :does_not_remove_any_todos], + [:guest, :guest, :removes_confidential_issues_and_merge_request_todos] + ] + end - it_behaves_like 'using different access permissions', PRIVATE_GROUP_PRIVATE_PROJECT_ACCESS_TABLE + with_them do + it_behaves_like 'using different access permissions' + end end context 'with nested groups' do @@ -320,23 +306,21 @@ RSpec.describe Todos::Destroy::EntityLeaveService do end context 'access permissions' do - # rubocop:disable RSpec/LeakyConstantDeclaration - INTERNAL_GROUP_INTERNAL_PROJECT_ACCESS_TABLE = - lambda do |_| - [ - # :group_access, :project_access, :c_todos, :mr_todos, :method - [nil, nil, :delete, :keep, :removes_only_confidential_issues_todos], - [nil, :reporter, :keep, :keep, :does_not_remove_any_todos], - [nil, :guest, :delete, :keep, :removes_only_confidential_issues_todos], - [:reporter, nil, :keep, :keep, :does_not_remove_any_todos], - [:guest, nil, :delete, :keep, :removes_only_confidential_issues_todos], - [:guest, :reporter, :keep, :keep, :does_not_remove_any_todos], - [:guest, :guest, :delete, :keep, :removes_only_confidential_issues_todos] - ] - end - # rubocop:enable RSpec/LeakyConstantDeclaration + where(:group_access, :project_access, :method_name) do + [ + [nil, nil, :removes_only_confidential_issues_todos], + [nil, :reporter, :does_not_remove_any_todos], + [nil, :guest, :removes_only_confidential_issues_todos], + [:reporter, nil, :does_not_remove_any_todos], + [:guest, nil, :removes_only_confidential_issues_todos], + [:guest, :reporter, :does_not_remove_any_todos], + [:guest, :guest, :removes_only_confidential_issues_todos] + ] + end - it_behaves_like 'using different access permissions', INTERNAL_GROUP_INTERNAL_PROJECT_ACCESS_TABLE + with_them do + it_behaves_like 'using different access permissions' + end end end end |