summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-07-22 16:26:33 -0600
committerDouwe Maan <douwe@selenight.nl>2016-07-22 16:26:33 -0600
commita205d44620595c901602cdad9958cf25e3a0f971 (patch)
tree216b21819c06b95281f677ac97adca6384551f66
parent46a17ffd5a200b4d2aca914ef5bafe46db1cb9bf (diff)
downloadgitlab-ce-nullify-note-type.tar.gz
Fix bug where replies to commit notes displayed in the MR discussion tab wouldn't show up on the commit pagenullify-note-type
-rw-r--r--CHANGELOG3
-rw-r--r--app/models/note.rb14
-rw-r--r--db/migrate/20160722221922_nullify_blank_type_on_notes.rb29
3 files changed, 41 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG
index fa272755033..3e28b35e2aa 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,9 @@ v 8.11.0 (unreleased)
- Retrieve rendered HTML from cache in one request
- Load project invited groups and members eagerly in ProjectTeam#fetch_members
+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
- Fix profile activity heatmap to show correct day name (eanplatter)
- Speed up ExternalWikiHelper#get_project_wiki_path
diff --git a/app/models/note.rb b/app/models/note.rb
index 9b0a7211b4e..b6b2ac6aa42 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -69,7 +69,7 @@ class Note < ActiveRecord::Base
project: [:project_members, { group: [:group_members] }])
end
- before_validation :clear_blank_line_code!
+ before_validation :nullify_blank_type, :nullify_blank_line_code
after_save :keep_around_commit
class << self
@@ -217,10 +217,6 @@ class Note < ActiveRecord::Base
!system?
end
- def clear_blank_line_code!
- self.line_code = nil if self.line_code.blank?
- end
-
def can_be_award_emoji?
noteable.is_a?(Awardable)
end
@@ -238,4 +234,12 @@ class Note < ActiveRecord::Base
def keep_around_commit
project.repository.keep_around(self.commit_id)
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
diff --git a/db/migrate/20160722221922_nullify_blank_type_on_notes.rb b/db/migrate/20160722221922_nullify_blank_type_on_notes.rb
new file mode 100644
index 00000000000..c6754529ff3
--- /dev/null
+++ b/db/migrate/20160722221922_nullify_blank_type_on_notes.rb
@@ -0,0 +1,29 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class NullifyBlankTypeOnNotes < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ # Set this constant to true if this migration requires downtime.
+ DOWNTIME = false
+
+ # When a migration requires downtime you **must** uncomment the following
+ # constant and define a short and easy to understand explanation as to why the
+ # migration requires downtime.
+ # DOWNTIME_REASON = ''
+
+ # When using the methods "add_concurrent_index" or "add_column_with_default"
+ # you must disable the use of transactions as these methods can not run in an
+ # existing transaction. When using "add_concurrent_index" make sure that this
+ # method is the _only_ method called in the migration, any other changes
+ # should go in a separate migration. This ensures that upon failure _only_ the
+ # index creation fails and can be retried or reverted easily.
+ #
+ # To disable transactions uncomment the following line and remove these
+ # comments:
+ # disable_ddl_transaction!
+
+ def up
+ execute "UPDATE notes SET type = NULL WHERE type = ''"
+ end
+end