summaryrefslogtreecommitdiff
path: root/app/models/group.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-26 14:51:57 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-26 14:51:57 +0300
commita5dbe353549ad71ce2868d67dee5226ad8d46e63 (patch)
treeb8d0f09bfd24f1c7a7275e48c85dc37b48be6fa3 /app/models/group.rb
parentdb03bfa86838020d5add006f8e7714d4a0823c32 (diff)
downloadgitlab-ce-a5dbe353549ad71ce2868d67dee5226ad8d46e63.tar.gz
Improve change group ownership logic
Diffstat (limited to 'app/models/group.rb')
-rw-r--r--app/models/group.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index 0593d9cd4bb..1c8eb98e0f2 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -32,6 +32,17 @@ class Group < Namespace
end
end
+ def change_owner(user)
+ self.owner = user
+ membership = users_groups.where(user_id: user.id).first
+
+ if membership
+ membership.update_attributes(group_access: UsersGroup::OWNER)
+ else
+ add_owner
+ end
+ end
+
private
def add_owner