Merge branch 'nullify-note-type' into 'master'

Fix bug where replies to commit notes displayed in the MR discussion tab wouldn'…

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/20157

See merge request !5446
This commit is contained in:
Stan Hu 2016-07-23 21:32:18 +00:00
commit 03738bdd48
3 changed files with 21 additions and 5 deletions

View file

@ -7,6 +7,9 @@ v 8.11.0 (unreleased)
- Load project invited groups and members eagerly in ProjectTeam#fetch_members - Load project invited groups and members eagerly in ProjectTeam#fetch_members
- Add GitLab Workhorse version to admin dashboard (Katarzyna Kobierska Ula Budziszewska) - Add GitLab Workhorse version to admin dashboard (Katarzyna Kobierska Ula Budziszewska)
v 8.10.1 (unreleased)
- Fix bug where replies to commit notes displayed in the MR discussion tab wouldn't show up on the commit page
v 8.10.0 v 8.10.0
- Fix profile activity heatmap to show correct day name (eanplatter) - Fix profile activity heatmap to show correct day name (eanplatter)
- Speed up ExternalWikiHelper#get_project_wiki_path - Speed up ExternalWikiHelper#get_project_wiki_path

View file

@ -69,7 +69,7 @@ class Note < ActiveRecord::Base
project: [:project_members, { group: [:group_members] }]) project: [:project_members, { group: [:group_members] }])
end end
before_validation :clear_blank_line_code! before_validation :nullify_blank_type, :nullify_blank_line_code
after_save :keep_around_commit after_save :keep_around_commit
class << self class << self
@ -217,10 +217,6 @@ class Note < ActiveRecord::Base
!system? !system?
end end
def clear_blank_line_code!
self.line_code = nil if self.line_code.blank?
end
def can_be_award_emoji? def can_be_award_emoji?
noteable.is_a?(Awardable) noteable.is_a?(Awardable)
end end
@ -238,4 +234,12 @@ class Note < ActiveRecord::Base
def keep_around_commit def keep_around_commit
project.repository.keep_around(self.commit_id) project.repository.keep_around(self.commit_id)
end end
def nullify_blank_type
self.type = nil if self.type.blank?
end
def nullify_blank_line_code
self.line_code = nil if self.line_code.blank?
end
end end

View file

@ -0,0 +1,9 @@
class NullifyBlankTypeOnNotes < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
execute "UPDATE notes SET type = NULL WHERE type = ''"
end
end