diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-03-06 21:13:27 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-03-06 21:13:27 +0000 |
commit | d617182a1a6f9b19a8a6d117fa3e507fa2b338a8 (patch) | |
tree | e24db462cfb8ed1854e2203a78d6d22b071232e5 /app/models | |
parent | f96d5112dca596fb85718b3cca2a7b30b3877207 (diff) | |
parent | b70d151db99d6d64f3514006c4fa6c8142e1b785 (diff) | |
download | gitlab-ce-d617182a1a6f9b19a8a6d117fa3e507fa2b338a8.tar.gz |
Merge branch 'master' into 'rs-carrierwave-db'rs-carrierwave-db
# Conflicts:
# spec/models/group_spec.rb
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/chat_team.rb | 5 | ||||
-rw-r--r-- | app/models/group.rb | 10 | ||||
-rw-r--r-- | app/models/namespace.rb | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/app/models/chat_team.rb b/app/models/chat_team.rb new file mode 100644 index 00000000000..7952141a0d6 --- /dev/null +++ b/app/models/chat_team.rb @@ -0,0 +1,5 @@ +class ChatTeam < ActiveRecord::Base + validates :team_id, presence: true + + belongs_to :namespace +end diff --git a/app/models/group.rb b/app/models/group.rb index a1f12ed55ea..bd0ecae3da4 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -213,4 +213,14 @@ class Group < Namespace def users_with_parents User.where(id: members_with_parents.select(:user_id)) end + + def mattermost_team_params + max_length = 59 + + { + name: path[0..max_length], + display_name: name[0..max_length], + type: public? ? 'O' : 'I' # Open vs Invite-only + } + end end diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 3137dd32f93..d350f1d6770 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -20,6 +20,7 @@ class Namespace < ActiveRecord::Base belongs_to :parent, class_name: "Namespace" has_many :children, class_name: "Namespace", foreign_key: :parent_id + has_one :chat_team, dependent: :destroy validates :owner, presence: true, unless: ->(n) { n.type == "Group" } validates :name, |