diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2017-05-03 22:11:19 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2017-05-04 12:58:41 +1100 |
commit | 62be3355b1cc74e085a7a046e7aca05f59a1f97a (patch) | |
tree | d2d01ebfac3f3af42046f9fd3348c966ea90a6d9 | |
parent | c2b869a119f7400d748a8a97e4abc3137bc7c51d (diff) | |
download | gitlab-ce-62be3355b1cc74e085a7a046e7aca05f59a1f97a.tar.gz |
Add alias_attributes for notes
-rw-r--r-- | app/models/note.rb | 3 | ||||
-rw-r--r-- | app/services/notes/update_service.rb | 4 | ||||
-rw-r--r-- | db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb | 14 | ||||
-rw-r--r-- | db/schema.rb | 2 | ||||
-rw-r--r-- | spec/services/notes/update_service_spec.rb | 7 |
5 files changed, 3 insertions, 27 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 943211ca991..002a1565d54 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -18,6 +18,9 @@ class Note < ActiveRecord::Base 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 # Banzai::ObjectRenderer. attr_accessor :redacted_note_html diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb index 4b4f383abf2..75fd08ea0a9 100644 --- a/app/services/notes/update_service.rb +++ b/app/services/notes/update_service.rb @@ -5,11 +5,7 @@ module Notes 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.create_new_cross_references!(current_user) if note.previous_changes.include?('note') diff --git a/db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb b/db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb deleted file mode 100644 index a44a1feab16..00000000000 --- a/db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb +++ /dev/null @@ -1,14 +0,0 @@ -# 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 diff --git a/db/schema.rb b/db/schema.rb index b173b467abf..20127cbed32 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -778,8 +778,6 @@ ActiveRecord::Schema.define(version: 20170503022548) do t.string "discussion_id" t.text "note_html" t.integer "cached_markdown_version" - t.datetime "last_edited_at" - t.integer "last_edited_by_id" end add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb index 8c3e4607f3e..905e2f46bde 100644 --- a/spec/services/notes/update_service_spec.rb +++ b/spec/services/notes/update_service_spec.rb @@ -20,13 +20,6 @@ describe Notes::UpdateService, services: true do @note.reload 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 let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) } |