2021-09-30 23:02:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe Members::Projects::CreatorService, feature_category: :projects do
|
2022-07-23 23:45:48 +05:30
|
|
|
let_it_be(:source, reload: true) { create(:project, :public) }
|
2023-06-20 00:43:36 +05:30
|
|
|
let_it_be(:source2, reload: true) { create(:project, :public) }
|
2022-07-23 23:45:48 +05:30
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
describe '.access_levels' do
|
2022-05-07 20:08:51 +05:30
|
|
|
it 'returns Gitlab::Access.sym_options_with_owner' do
|
|
|
|
expect(described_class.access_levels).to eq(Gitlab::Access.sym_options_with_owner)
|
2021-09-30 23:02:18 +05:30
|
|
|
end
|
|
|
|
end
|
2022-07-16 23:28:13 +05:30
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
it_behaves_like 'owner management'
|
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
describe '.add_members' do
|
2022-07-23 23:45:48 +05:30
|
|
|
it_behaves_like 'bulk member creation' do
|
2023-06-20 00:43:36 +05:30
|
|
|
let_it_be(:source_type) { Project }
|
2022-07-23 23:45:48 +05:30
|
|
|
let_it_be(:member_type) { ProjectMember }
|
|
|
|
end
|
|
|
|
end
|
2022-07-16 23:28:13 +05:30
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
describe '.add_member' do
|
2022-07-16 23:28:13 +05:30
|
|
|
it_behaves_like 'member creation' do
|
|
|
|
let_it_be(:member_type) { ProjectMember }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'authorized projects update' do
|
|
|
|
it 'schedules a single project authorization update job when called multiple times' do
|
2023-04-23 21:23:45 +05:30
|
|
|
stub_feature_flags(do_not_run_safety_net_auth_refresh_jobs: false)
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to receive(:bulk_perform_in).once
|
|
|
|
|
|
|
|
1.upto(3) do
|
2022-08-13 15:12:31 +05:30
|
|
|
described_class.add_member(source, user, :maintainer)
|
2022-07-16 23:28:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-09-30 23:02:18 +05:30
|
|
|
end
|