Merge branch '20512-fix-rename-add-users-into-project-to-add-users-to-project-and-projects-ids-to-project-ids' into 'master'
Fix Rename `add_users_into_project` and `projects_ids` ## What does this MR do? Only modifies the name of a method that leaves more semantic and expressive and the name of the keywords arguments to the rails convention. ## Are there points in the code the reviewer needs to double check? Only if it has been changed at every point that is calling this method and that passing arguments. ## Why was this MR needed? To make the code more expressive. ## What are the relevant issue numbers? Closes #20512. - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5659
This commit is contained in:
commit
db69111a63
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