diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-04-26 16:57:23 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-04-26 16:57:23 +0300 |
commit | c7df97710b5b519c8ea1b5bb92ae17579082d3f4 (patch) | |
tree | 70a748887b18194f48f09830a18b83dbb8a57b68 | |
parent | 465a818061977b99c1756fe1c32b004ef035d3c0 (diff) | |
parent | 0e24b1280eca55bbe52931e530f3ce6ee38addc1 (diff) |
Merge branch 'backport-md-cache-fix' into 'master'
Work around a hard-to-understand failure in `CacheMarkdownField`
See merge request !10918
-rw-r--r-- | app/models/concerns/cache_markdown_field.rb | 4 | ||||
-rw-r--r-- | spec/models/concerns/cache_markdown_field_spec.rb | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/app/models/concerns/cache_markdown_field.rb b/app/models/concerns/cache_markdown_field.rb index 2eedc143968..f033028c4e5 100644 --- a/app/models/concerns/cache_markdown_field.rb +++ b/app/models/concerns/cache_markdown_field.rb @@ -120,7 +120,9 @@ module CacheMarkdownField attrs end - before_save :refresh_markdown_cache!, if: :invalidated_markdown_cache? + # Using before_update here conflicts with elasticsearch-model somehow + before_create :refresh_markdown_cache!, if: :invalidated_markdown_cache? + before_update :refresh_markdown_cache!, if: :invalidated_markdown_cache? end class_methods do diff --git a/spec/models/concerns/cache_markdown_field_spec.rb b/spec/models/concerns/cache_markdown_field_spec.rb index de0069bdcac..4edafbc4e32 100644 --- a/spec/models/concerns/cache_markdown_field_spec.rb +++ b/spec/models/concerns/cache_markdown_field_spec.rb @@ -18,7 +18,7 @@ describe CacheMarkdownField do end extend ActiveModel::Callbacks - define_model_callbacks :save + define_model_callbacks :create, :update include CacheMarkdownField cache_markdown_field :foo @@ -56,7 +56,7 @@ describe CacheMarkdownField do end def save - run_callbacks :save do + run_callbacks :update do changes_applied end end |