Fix Rename add_users_into_project
and projects_ids
We never add things `into` projects, we just add them `to` projects. So how about we rename this to `add_users_to_project`. Rename `projects_ids` to `project_ids` by following the convention of rails.
This commit is contained in:
parent
f4c79d6a84
commit
f15ed5f0a5
6 changed files with 15 additions and 14 deletions
|
@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
|
|||
|
||||
v 8.11.0 (unreleased)
|
||||
- Fix don't pass a local variable called `i` to a partial. !20510 (herminiotorres)
|
||||
- Fix rename `add_users_into_project` and `projects_ids`. !20512 (herminiotorres)
|
||||
- Fix the title of the toggle dropdown button. !5515 (herminiotorres)
|
||||
- Improve diff performance by eliminating redundant checks for text blobs
|
||||
- Convert switch icon into icon font (ClemMakesApps)
|
||||
|
|
|
@ -21,19 +21,19 @@ class ProjectMember < Member
|
|||
# or symbol like :master representing role
|
||||
#
|
||||
# Ex.
|
||||
# add_users_into_projects(
|
||||
# add_users_to_projects(
|
||||
# project_ids,
|
||||
# user_ids,
|
||||
# ProjectMember::MASTER
|
||||
# )
|
||||
#
|
||||
# add_users_into_projects(
|
||||
# add_users_to_projects(
|
||||
# project_ids,
|
||||
# user_ids,
|
||||
# :master
|
||||
# )
|
||||
#
|
||||
def add_users_into_projects(project_ids, user_ids, access, current_user = nil)
|
||||
def add_users_to_projects(project_ids, user_ids, access, current_user = nil)
|
||||
access_level = if roles_hash.has_key?(access)
|
||||
roles_hash[access]
|
||||
elsif roles_hash.values.include?(access.to_i)
|
||||
|
|
|
@ -34,7 +34,7 @@ class ProjectTeam
|
|||
end
|
||||
|
||||
def add_users(users, access, current_user = nil)
|
||||
ProjectMember.add_users_into_projects(
|
||||
ProjectMember.add_users_to_projects(
|
||||
[project.id],
|
||||
users,
|
||||
access,
|
||||
|
|
|
@ -4,13 +4,13 @@ namespace :gitlab do
|
|||
task all_users_to_all_projects: :environment do |t, args|
|
||||
user_ids = User.where(admin: false).pluck(:id)
|
||||
admin_ids = User.where(admin: true).pluck(:id)
|
||||
projects_ids = Project.pluck(:id)
|
||||
project_ids = Project.pluck(:id)
|
||||
|
||||
puts "Importing #{user_ids.size} users into #{projects_ids.size} projects"
|
||||
ProjectMember.add_users_into_projects(projects_ids, user_ids, ProjectMember::DEVELOPER)
|
||||
puts "Importing #{user_ids.size} users into #{project_ids.size} projects"
|
||||
ProjectMember.add_users_to_projects(project_ids, user_ids, ProjectMember::DEVELOPER)
|
||||
|
||||
puts "Importing #{admin_ids.size} admins into #{projects_ids.size} projects"
|
||||
ProjectMember.add_users_into_projects(projects_ids, admin_ids, ProjectMember::MASTER)
|
||||
puts "Importing #{admin_ids.size} admins into #{project_ids.size} projects"
|
||||
ProjectMember.add_users_to_projects(project_ids, admin_ids, ProjectMember::MASTER)
|
||||
end
|
||||
|
||||
desc "GitLab | Add a specific user to all projects (as a developer)"
|
||||
|
@ -18,7 +18,7 @@ namespace :gitlab do
|
|||
user = User.find_by(email: args.email)
|
||||
project_ids = Project.pluck(:id)
|
||||
puts "Importing #{user.email} users into #{project_ids.size} projects"
|
||||
ProjectMember.add_users_into_projects(project_ids, Array.wrap(user.id), ProjectMember::DEVELOPER)
|
||||
ProjectMember.add_users_to_projects(project_ids, Array.wrap(user.id), ProjectMember::DEVELOPER)
|
||||
end
|
||||
|
||||
desc "GitLab | Add all users to all groups (admin users are added as owners)"
|
||||
|
|
|
@ -26,10 +26,10 @@ namespace :gitlab do
|
|||
namespace_path = ENV['NAMESPACE']
|
||||
|
||||
projects = find_projects(namespace_path)
|
||||
projects_ids = projects.pluck(:id)
|
||||
project_ids = projects.pluck(:id)
|
||||
|
||||
puts "Removing webhooks with the url '#{web_hook_url}' ... "
|
||||
count = WebHook.where(url: web_hook_url, project_id: projects_ids, type: 'ProjectHook').delete_all
|
||||
count = WebHook.where(url: web_hook_url, project_id: project_ids, type: 'ProjectHook').delete_all
|
||||
puts "#{count} webhooks were removed."
|
||||
end
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ describe ProjectMember, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.add_users_into_projects' do
|
||||
describe '.add_users_to_projects' do
|
||||
before do
|
||||
@project_1 = create :project
|
||||
@project_2 = create :project
|
||||
|
@ -109,7 +109,7 @@ describe ProjectMember, models: true do
|
|||
@user_1 = create :user
|
||||
@user_2 = create :user
|
||||
|
||||
ProjectMember.add_users_into_projects(
|
||||
ProjectMember.add_users_to_projects(
|
||||
[@project_1.id, @project_2.id],
|
||||
[@user_1.id, @user_2.id],
|
||||
ProjectMember::MASTER
|
||||
|
|
Loading…
Reference in a new issue