debian-mirror-gitlab/spec/support/helpers/project_helpers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.5 KiB
Ruby
Raw Normal View History

2019-10-03 12:08:05 +05:30
# frozen_string_literal: true
module ProjectHelpers
# @params target [Project] membership target
# @params membership [Symbol] accepts the membership levels :guest, :reporter...
# and phony levels :non_member and :anonymous
def create_user_from_membership(target, membership)
case membership
when :anonymous
nil
when :non_member
create(:user, name: membership)
2019-12-04 20:38:33 +05:30
when :admin
create(:user, :admin, name: 'admin')
2019-10-03 12:08:05 +05:30
else
2022-08-13 15:12:31 +05:30
create(:user, name: membership).tap { |u| target.add_member(u, membership) }
2019-10-03 12:08:05 +05:30
end
end
2022-07-23 23:45:48 +05:30
def update_feature_access_level(project, access_level, additional_params = {})
2019-12-04 20:38:33 +05:30
features = ProjectFeature::FEATURES.dup
features.delete(:pages)
params = features.each_with_object({}) { |feature, h| h["#{feature}_access_level"] = access_level }
2022-07-23 23:45:48 +05:30
project.update!(params.merge(additional_params))
2019-10-03 12:08:05 +05:30
end
2022-07-16 23:28:13 +05:30
def create_project_with_statistics(namespace = nil, with_data: false, size_multiplier: 1)
project = namespace.present? ? create(:project, namespace: namespace) : create(:project)
project.tap do |p|
create(:project_statistics, project: p, with_data: with_data, size_multiplier: size_multiplier)
end
end
def grace_months_after_deletion_notification
(::Gitlab::CurrentSettings.inactive_projects_delete_after_months -
::Gitlab::CurrentSettings.inactive_projects_send_warning_email_after_months).months
end
def deletion_date
Date.parse(grace_months_after_deletion_notification.from_now.to_s).to_s
end
2019-10-03 12:08:05 +05:30
end