Commit 62be3355 authored by blackst0ne's avatar blackst0ne

Add alias_attributes for notes

parent c2b869a1
...@@ -18,6 +18,9 @@ class Note < ActiveRecord::Base ...@@ -18,6 +18,9 @@ class Note < ActiveRecord::Base
cache_markdown_field :note, pipeline: :note, issuable_state_filter_enabled: true cache_markdown_field :note, pipeline: :note, issuable_state_filter_enabled: true
alias_attribute :last_edited_at, :updated_at
alias_attribute :last_edited_by, :updated_by
# Attribute containing rendered and redacted Markdown as generated by # Attribute containing rendered and redacted Markdown as generated by
# Banzai::ObjectRenderer. # Banzai::ObjectRenderer.
attr_accessor :redacted_note_html attr_accessor :redacted_note_html
......
...@@ -5,11 +5,7 @@ module Notes ...@@ -5,11 +5,7 @@ module Notes
old_mentioned_users = note.mentioned_users.to_a old_mentioned_users = note.mentioned_users.to_a
note.assign_attributes(params)
params.merge!(last_edited_at: Time.now, last_edited_by: current_user) if note.note_changed?
note.update_attributes(params.merge(updated_by: current_user)) note.update_attributes(params.merge(updated_by: current_user))
note.create_new_cross_references!(current_user) note.create_new_cross_references!(current_user)
if note.previous_changes.include?('note') if note.previous_changes.include?('note')
......
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class AddLastEditedAtAndLastEditedByIdToNotes < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
def change
add_column :notes, :last_edited_at, :timestamp
add_column :notes, :last_edited_by_id, :integer
end
end
...@@ -778,8 +778,6 @@ ActiveRecord::Schema.define(version: 20170503022548) do ...@@ -778,8 +778,6 @@ ActiveRecord::Schema.define(version: 20170503022548) do
t.string "discussion_id" t.string "discussion_id"
t.text "note_html" t.text "note_html"
t.integer "cached_markdown_version" t.integer "cached_markdown_version"
t.datetime "last_edited_at"
t.integer "last_edited_by_id"
end end
add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree
......
...@@ -20,13 +20,6 @@ describe Notes::UpdateService, services: true do ...@@ -20,13 +20,6 @@ describe Notes::UpdateService, services: true do
@note.reload @note.reload
end end
it 'updates last_edited_at and last_edited_by attributes' do
update_note({ note: 'Hello world!' })
expect(@note.last_edited_at).not_to be_nil
expect(@note.last_edited_by).not_to be_nil
end
context 'todos' do context 'todos' do
let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) } let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment