diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-28 21:11:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-28 21:11:01 +0300 |
commit | 7c5f1bfac791045e54386b9c9bb56ee24afc68ca (patch) | |
tree | a11c8dff3994899c25acacb383c0a70522a24cd1 /spec/services | |
parent | d62fd6e04c272d48dccde4033529ca97c27502f6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
3 files changed, 45 insertions, 7 deletions
diff --git a/spec/services/ci/pipeline_schedules/create_service_spec.rb b/spec/services/ci/pipeline_schedules/create_service_spec.rb index a01c71432c3..3fc093c13da 100644 --- a/spec/services/ci/pipeline_schedules/create_service_spec.rb +++ b/spec/services/ci/pipeline_schedules/create_service_spec.rb @@ -3,9 +3,11 @@ require 'spec_helper' RSpec.describe Ci::PipelineSchedules::CreateService, feature_category: :continuous_integration do - let_it_be(:user) { create(:user) } let_it_be(:reporter) { create(:user) } - let_it_be(:project) { create(:project, :public, :repository) } + let_it_be_with_reload(:user) { create(:user) } + let_it_be_with_reload(:project) { create(:project, :public, :repository) } + + subject(:service) { described_class.new(project, user, params) } before_all do project.add_maintainer(user) @@ -82,5 +84,7 @@ RSpec.describe Ci::PipelineSchedules::CreateService, feature_category: :continuo end end end + + it_behaves_like 'pipeline schedules checking variables permission' end end diff --git a/spec/services/ci/pipeline_schedules/update_service_spec.rb b/spec/services/ci/pipeline_schedules/update_service_spec.rb index c31a652ed93..834bbcfcfeb 100644 --- a/spec/services/ci/pipeline_schedules/update_service_spec.rb +++ b/spec/services/ci/pipeline_schedules/update_service_spec.rb @@ -3,16 +3,18 @@ require 'spec_helper' RSpec.describe Ci::PipelineSchedules::UpdateService, feature_category: :continuous_integration do - let_it_be(:user) { create(:user) } + let_it_be_with_reload(:user) { create(:user) } + let_it_be_with_reload(:project) { create(:project, :public, :repository) } + let_it_be_with_reload(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: user) } let_it_be(:reporter) { create(:user) } - let_it_be(:project) { create(:project, :public, :repository) } - let_it_be(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: user) } let_it_be(:pipeline_schedule_variable) do create(:ci_pipeline_schedule_variable, key: 'foo', value: 'foovalue', pipeline_schedule: pipeline_schedule) end + subject(:service) { described_class.new(pipeline_schedule, user, params) } + before_all do project.add_maintainer(user) project.add_reporter(reporter) @@ -123,5 +125,7 @@ RSpec.describe Ci::PipelineSchedules::UpdateService, feature_category: :continuo end end end + + it_behaves_like 'pipeline schedules checking variables permission' end end diff --git a/spec/services/todos/destroy/group_private_service_spec.rb b/spec/services/todos/destroy/group_private_service_spec.rb index be470688084..b3185bc72ff 100644 --- a/spec/services/todos/destroy/group_private_service_spec.rb +++ b/spec/services/todos/destroy/group_private_service_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Todos::Destroy::GroupPrivateService, feature_category: :team_plan let!(:todo_group_member) { create(:todo, user: group_member, group: group) } let!(:todo_project_member) { create(:todo, user: project_member, group: group) } - describe '#execute' do + describe '#execute', :aggregate_failures do before do group.add_developer(group_member) project.add_developer(project_member) @@ -57,7 +57,37 @@ RSpec.describe Todos::Destroy::GroupPrivateService, feature_category: :team_plan end it 'removes todos only for users who are not group users' do - expect { subject }.to change { Todo.count }.from(7).to(5) + expect { subject }.to change { Todo.count }.from(7).to(4) + + expect(parent_member.todos).to contain_exactly(todo_parent_member) + expect(subgroup_member.todos).to be_empty + expect(subgproject_member.todos).to contain_exactly(todo_subproject_member) + end + end + + context 'with member via group share' do + let(:invited_group) { create(:group) } + let(:invited_group_member) { create(:user).tap { |u| invited_group.add_guest(u) } } + + let!(:todo_invited_group_member) { create(:todo, user: invited_group_member, group: group) } + + it 'does not remove todos for users invited to the group' do + create(:group_group_link, shared_group: group, shared_with_group: invited_group) + + expect { subject }.to change { Todo.count }.from(5).to(3) + + expect(invited_group_member.todos).to contain_exactly(todo_invited_group_member) + end + + it 'does not remove todos for users invited to an ancestor group' do + parent_group = create(:group) + group.update!(parent: parent_group) + + create(:group_group_link, shared_group: parent_group, shared_with_group: invited_group) + + expect { subject }.to change { Todo.count }.from(5).to(3) + + expect(invited_group_member.todos).to contain_exactly(todo_invited_group_member) end end end |