Commit 534419ba authored by Patrick Bajao's avatar Patrick Bajao

Fix error when displaying discussions with note without an author

parent 44480a4c
...@@ -582,7 +582,7 @@ class Note < ApplicationRecord ...@@ -582,7 +582,7 @@ class Note < ApplicationRecord
end end
def post_processed_cache_key def post_processed_cache_key
cache_key_items = [cache_key, author.cache_key] cache_key_items = [cache_key, author&.cache_key]
cache_key_items << Digest::SHA1.hexdigest(redacted_note_html) if redacted_note_html.present? cache_key_items << Digest::SHA1.hexdigest(redacted_note_html) if redacted_note_html.present?
cache_key_items.join(':') cache_key_items.join(':')
......
...@@ -1576,6 +1576,14 @@ RSpec.describe Note do ...@@ -1576,6 +1576,14 @@ RSpec.describe Note do
expect(note.post_processed_cache_key).to eq("#{note.cache_key}:#{note.author.cache_key}") expect(note.post_processed_cache_key).to eq("#{note.cache_key}:#{note.author.cache_key}")
end end
context 'when note has no author' do
let(:note) { build(:note, author: nil) }
it 'returns cache key only' do
expect(note.post_processed_cache_key).to eq("#{note.cache_key}:")
end
end
context 'when note has redacted_note_html' do context 'when note has redacted_note_html' do
let(:redacted_note_html) { 'redacted note html' } let(:redacted_note_html) { 'redacted note html' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment