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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
5b99f05f
Commit
5b99f05f
authored
Jan 24, 2022
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache timeline event note markdown
parent
eeceb35f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
ee/app/models/incident_management/timeline_event.rb
ee/app/models/incident_management/timeline_event.rb
+4
-0
ee/spec/models/incident_management/timeline_event_spec.rb
ee/spec/models/incident_management/timeline_event_spec.rb
+33
-1
No files found.
ee/app/models/incident_management/timeline_event.rb
View file @
5b99f05f
...
...
@@ -2,8 +2,12 @@
module
IncidentManagement
class
TimelineEvent
<
ApplicationRecord
include
CacheMarkdownField
self
.
table_name
=
'incident_management_timeline_events'
cache_markdown_field
:note
,
pipeline: :note
,
issuable_reference_expansion_enabled:
true
belongs_to
:project
belongs_to
:author
,
class_name:
'User'
,
foreign_key: :author_id
belongs_to
:incident
,
class_name:
'Issue'
,
foreign_key: :issue_id
,
inverse_of: :incident_management_timeline_events
...
...
ee/spec/models/incident_management/timeline_event_spec.rb
View file @
5b99f05f
...
...
@@ -4,7 +4,8 @@ require 'spec_helper'
RSpec
.
describe
IncidentManagement
::
TimelineEvent
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:timeline_event
)
{
create
(
:incident_management_timeline_event
,
project:
project
)
}
let_it_be
(
:incident
)
{
create
(
:incident
,
project:
project
)
}
let_it_be
(
:timeline_event
)
{
create
(
:incident_management_timeline_event
,
project:
project
,
incident:
incident
)
}
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:project
)
}
...
...
@@ -38,4 +39,35 @@ RSpec.describe IncidentManagement::TimelineEvent do
is_expected
.
to
eq
([
occurred_3mins_ago
,
occurred_2mins_ago
,
timeline_event
])
end
end
describe
'#cache_markdown_field'
do
let
(
:note
)
{
'<p>some html</p>'
}
let
(
:expected_note_html
)
{
'<p dir="auto">some html</p>'
}
before
do
allow
(
Banzai
::
Renderer
).
to
receive
(
:cacheless_render_field
).
and_call_original
end
context
'on create'
do
let
(
:timeline_event
)
{
build
(
:incident_management_timeline_event
,
project:
project
,
incident:
incident
,
note:
note
)
}
it
'updates note_html'
,
:aggregate_failures
do
expect
(
Banzai
::
Renderer
).
to
receive
(
:cacheless_render_field
)
.
with
(
timeline_event
,
:note
,
{
skip_project_check:
false
})
expect
{
timeline_event
.
save!
}.
to
change
{
timeline_event
.
note_html
}.
to
(
expected_note_html
)
end
end
context
'on update'
do
let
(
:timeline_event
)
{
create
(
:incident_management_timeline_event
,
project:
project
,
incident:
incident
)
}
it
'updates note_html'
,
:aggregate_failures
do
expect
(
Banzai
::
Renderer
).
to
receive
(
:cacheless_render_field
)
.
with
(
timeline_event
,
:note
,
{
skip_project_check:
false
})
expect
{
timeline_event
.
update!
(
note:
note
)
}.
to
change
{
timeline_event
.
note_html
}.
to
(
expected_note_html
)
end
end
end
end
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