diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 21:52:54 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 21:52:54 +0300 |
commit | 1aa48174db63871bb10b53e49c86222a4d9b7c6d (patch) | |
tree | 63de989577bd4304dbeee82bfb2a1e41bbdd4976 /app/models/members | |
parent | 13af7de9411ef20fcab00f7c5d7cdc6b90dbd4b7 (diff) | |
download | gitlab-ce-1aa48174db63871bb10b53e49c86222a4d9b7c6d.tar.gz |
Fix STI+polymorphic for Group <-> GroupMember
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/members')
-rw-r--r-- | app/models/members/group_member.rb | 5 | ||||
-rw-r--r-- | app/models/members/project_member.rb | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb index e7eb4a18e34..e72393c4278 100644 --- a/app/models/members/group_member.rb +++ b/app/models/members/group_member.rb @@ -1,11 +1,12 @@ class GroupMember < Member - SOURCE_TYPE = 'Group' + SOURCE_TYPE = 'Namespace' belongs_to :group, class_name: 'Group', foreign_key: 'source_id' # Make sure group member points only to group as it source default_value_for :source_type, SOURCE_TYPE - validates_format_of :source_type, with: /\AGroup\z/ + default_value_for :notification_level, Notification::N_GLOBAL + validates_format_of :source_type, with: /\ANamespace\z/ default_scope { where(source_type: SOURCE_TYPE) } scope :with_group, ->(group) { where(source_id: group.id) } diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb index 3f8137ed06e..f14900ad3e6 100644 --- a/app/models/members/project_member.rb +++ b/app/models/members/project_member.rb @@ -5,8 +5,10 @@ class ProjectMember < Member belongs_to :project, class_name: 'Project', foreign_key: 'source_id' + # Make sure project member points only to project as it source default_value_for :source_type, SOURCE_TYPE + default_value_for :notification_level, Notification::N_GLOBAL validates_format_of :source_type, with: /\AProject\z/ default_scope { where(source_type: SOURCE_TYPE) } |