Skip to content

Commit c7df977

Browse files
committed
Merge branch 'backport-md-cache-fix' into 'master'
Work around a hard-to-understand failure in `CacheMarkdownField` See merge request !10918
2 parents 465a818 + 0e24b12 commit c7df977

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/models/concerns/cache_markdown_field.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ def attributes
120120
attrs
121121
end
122122

123-
before_save :refresh_markdown_cache!, if: :invalidated_markdown_cache?
123+
# Using before_update here conflicts with elasticsearch-model somehow
124+
before_create :refresh_markdown_cache!, if: :invalidated_markdown_cache?
125+
before_update :refresh_markdown_cache!, if: :invalidated_markdown_cache?
124126
end
125127

126128
class_methods do

spec/models/concerns/cache_markdown_field_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def attributes
1818
end
1919

2020
extend ActiveModel::Callbacks
21-
define_model_callbacks :save
21+
define_model_callbacks :create, :update
2222

2323
include CacheMarkdownField
2424
cache_markdown_field :foo
@@ -56,7 +56,7 @@ def write_attribute(name, value)
5656
end
5757

5858
def save
59-
run_callbacks :save do
59+
run_callbacks :update do
6060
changes_applied
6161
end
6262
end

0 commit comments

Comments
 (0)