summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-04-19 12:49:19 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2018-04-19 12:49:19 +0000
commit9cc011fdedab44f7423ed24150c93117abc689aa (patch)
treecbd0c30fef80e1ba67309030bbbbb4e4cd65d231 /app/models
parente01e648075218d9583c488cdd9d3567048df55d7 (diff)
parent90716733522691e964680539e231d3677bafbc51 (diff)
downloadgitlab-ce-9cc011fdedab44f7423ed24150c93117abc689aa.tar.gz
Merge branch 'blackst0ne-rails5-update-user-manageable-groups' into 'master'
[Rails5] Fix `User#manageable_groups` See merge request gitlab-org/gitlab-ce!18330
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 7a42d546b9c..b0668148972 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -947,10 +947,13 @@ class User < ActiveRecord::Base
end
def manageable_groups
- union = Gitlab::SQL::Union.new([owned_groups.select(:id),
- masters_groups.select(:id)])
- arel_union = Arel::Nodes::SqlLiteral.new(union.to_sql)
- owned_and_master_groups = Group.where(Group.arel_table[:id].in(arel_union))
+ union_sql = Gitlab::SQL::Union.new([owned_groups.select(:id), masters_groups.select(:id)]).to_sql
+
+ # Update this line to not use raw SQL when migrated to Rails 5.2.
+ # Either ActiveRecord or Arel constructions are fine.
+ # This was replaced with the raw SQL construction because of bugs in the arel gem.
+ # Bugs were fixed in arel 9.0.0 (Rails 5.2).
+ owned_and_master_groups = Group.where("namespaces.id IN (#{union_sql})") # rubocop:disable GitlabSecurity/SqlInjection
Gitlab::GroupHierarchy.new(owned_and_master_groups).base_and_descendants
end