diff options
author | Ciro Santilli <ciro.santilli@gmail.com> | 2014-10-09 11:47:47 +0400 |
---|---|---|
committer | Ciro Santilli <ciro.santilli@gmail.com> | 2015-01-01 23:12:00 +0300 |
commit | 33c9f05c6bb90a995ddc685b4a22479f17c575e5 (patch) | |
tree | 8dd374b515eeb5e9194ab3c52e46b569cfb5f2e8 /app/models | |
parent | ac1584249c262e447a6360734597fa17fe077718 (diff) |
Append in place for strings and arrays
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ability.rb | 26 | ||||
-rw-r--r-- | app/models/concerns/mentionable.rb | 2 | ||||
-rw-r--r-- | app/models/merge_request.rb | 3 | ||||
-rw-r--r-- | app/models/network/graph.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | app/models/project_team.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 4 |
7 files changed, 21 insertions, 20 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index 97a72bf3635..890417e780d 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -73,28 +73,28 @@ class Ability # Rules based on role in project if team.master?(user) - rules += project_master_rules + rules.push(*project_master_rules) elsif team.developer?(user) - rules += project_dev_rules + rules.push(*project_dev_rules) elsif team.reporter?(user) - rules += project_report_rules + rules.push(*project_report_rules) elsif team.guest?(user) - rules += project_guest_rules + rules.push(*project_guest_rules) end if project.public? || project.internal? - rules += public_project_rules + rules.push(*public_project_rules) end if project.owner == user || user.admin? - rules += project_admin_rules + rules.push(*project_admin_rules) end if project.group && project.group.has_owner?(user) - rules += project_admin_rules + rules.push(*project_admin_rules) end if project.archived? @@ -193,17 +193,17 @@ class Ability # Only group masters and group owners can create new projects in group if group.has_master?(user) || group.has_owner?(user) || user.admin? - rules += [ + rules.push(*[ :create_projects, - ] + ]) end # Only group owner and administrators can manage group if group.has_owner?(user) || user.admin? - rules += [ + rules.push(*[ :manage_group, :manage_namespace - ] + ]) end rules.flatten @@ -214,10 +214,10 @@ class Ability # Only namespace owner and administrators can manage it if namespace.owner == user || user.admin? - rules += [ + rules.push(*[ :create_projects, :manage_namespace - ] + ]) end rules.flatten diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb index 6c1aa99668a..66f83b932d4 100644 --- a/app/models/concerns/mentionable.rb +++ b/app/models/concerns/mentionable.rb @@ -50,7 +50,7 @@ module Mentionable matches.each do |match| identifier = match.delete "@" if identifier == "all" - users += project.team.members.flatten + users.push(*project.team.members.flatten) else id = User.find_by(username: identifier).try(:id) users << User.find(id) unless id.blank? diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 2cc427d35c2..5dc3c403b3b 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -248,7 +248,8 @@ class MergeRequest < ActiveRecord::Base def closes_issues if target_branch == project.default_branch issues = commits.flat_map { |c| c.closes_issues(project) } - issues += Gitlab::ClosingIssueExtractor.closed_by_message_in_project(description, project) + issues.push(*Gitlab::ClosingIssueExtractor. + closed_by_message_in_project(description, project)) issues.uniq.sort_by(&:id) else [] diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb index 43979b5e807..f13a40cf4f6 100644 --- a/app/models/network/graph.rb +++ b/app/models/network/graph.rb @@ -226,7 +226,7 @@ module Network reserved = [] for day in time_range - reserved += @reserved[day] + reserved.push(*@reserved[day]) end reserved.uniq! diff --git a/app/models/project.rb b/app/models/project.rb index b0c379e6157..67898955d63 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -170,7 +170,7 @@ class Project < ActiveRecord::Base def publicish(user) visibility_levels = [Project::PUBLIC] - visibility_levels += [Project::INTERNAL] if user + visibility_levels << Project::INTERNAL if user where(visibility_level: visibility_levels) end diff --git a/app/models/project_team.rb b/app/models/project_team.rb index 657ee23ae23..bc9c3ce58f6 100644 --- a/app/models/project_team.rb +++ b/app/models/project_team.rb @@ -160,7 +160,7 @@ class ProjectTeam end user_ids = project_members.pluck(:user_id) - user_ids += group_members.pluck(:user_id) if group + user_ids.push(*group_members.pluck(:user_id)) if group User.where(id: user_ids) end diff --git a/app/models/user.rb b/app/models/user.rb index 7dae318e780..33a0d03370e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -297,8 +297,8 @@ class User < ActiveRecord::Base def authorized_projects @authorized_projects ||= begin project_ids = personal_projects.pluck(:id) - project_ids += groups_projects.pluck(:id) - project_ids += projects.pluck(:id).uniq + project_ids.push(*groups_projects.pluck(:id)) + project_ids.push(*projects.pluck(:id).uniq) Project.where(id: project_ids).joins(:namespace).order('namespaces.name ASC') end end |