diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-02-28 08:48:23 +0100 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-03-07 12:27:50 +0100 |
commit | dcdfa04b322db3905f6871a6857e7055c556547f (patch) | |
tree | b3d006e8410b7182c63bfd620b99a71392c77aff /app/models/note.rb | |
parent | 8a0052c037f025b64159ca8cfe0d3451261c1edb (diff) | |
download | gitlab-ce-dcdfa04b322db3905f6871a6857e7055c556547f.tar.gz |
Add discussion APIjprovazn-api
* adds basic discussions API for issues and snippets
* reorganizes notes specs (so same tests can be used for all noteable types - issues, MRs, snippets)
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index d7a67ec277c..787a80f0196 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -81,7 +81,7 @@ class Note < ActiveRecord::Base validates :author, presence: true validates :discussion_id, presence: true, format: { with: /\A\h{40}\z/ } - validate unless: [:for_commit?, :importing?, :for_personal_snippet?] do |note| + validate unless: [:for_commit?, :importing?, :skip_project_check?] do |note| unless note.noteable.try(:project) == note.project errors.add(:project, 'does not match noteable project') end @@ -228,7 +228,7 @@ class Note < ActiveRecord::Base end def skip_project_check? - for_personal_snippet? + !for_project_noteable? end def commit @@ -308,6 +308,11 @@ class Note < ActiveRecord::Base self.noteable.supports_discussions? && !part_of_discussion? end + def can_create_todo? + # Skip system notes, and notes on project snippet + !system? && !for_snippet? + end + def discussion_class(noteable = nil) # When commit notes are rendered on an MR's Discussion page, they are # displayed in one discussion instead of individually. |