Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
62be3355
Commit
62be3355
authored
May 03, 2017
by
blackst0ne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add alias_attributes for notes
parent
c2b869a1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3 additions
and
27 deletions
+3
-27
app/models/note.rb
app/models/note.rb
+3
-0
app/services/notes/update_service.rb
app/services/notes/update_service.rb
+0
-4
db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb
...2512_add_last_edited_at_and_last_edited_by_id_to_notes.rb
+0
-14
db/schema.rb
db/schema.rb
+0
-2
spec/services/notes/update_service_spec.rb
spec/services/notes/update_service_spec.rb
+0
-7
No files found.
app/models/note.rb
View file @
62be3355
...
@@ -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
...
...
app/services/notes/update_service.rb
View file @
62be3355
...
@@ -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'
)
...
...
db/migrate/20170503022512_add_last_edited_at_and_last_edited_by_id_to_notes.rb
deleted
100644 → 0
View file @
c2b869a1
# 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
db/schema.rb
View file @
62be3355
...
@@ -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
...
...
spec/services/notes/update_service_spec.rb
View file @
62be3355
...
@@ -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
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment