diff options
Diffstat (limited to 'spec/models/discussion_spec.rb')
-rw-r--r-- | spec/models/discussion_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/discussion_spec.rb b/spec/models/discussion_spec.rb index 021940be0c2..2b33de96e04 100644 --- a/spec/models/discussion_spec.rb +++ b/spec/models/discussion_spec.rb @@ -51,4 +51,22 @@ RSpec.describe Discussion do expect(policy).to be_a(NotePolicy) end end + + describe '#cache_key' do + let(:notes_sha) { Digest::SHA1.hexdigest("#{first_note.id}:#{second_note.id}:#{third_note.id}") } + + it 'returns the cache key with ID and latest updated note updated at' do + expect(subject.cache_key).to eq("#{described_class::CACHE_VERSION}:#{third_note.latest_cached_markdown_version}:#{subject.id}:#{notes_sha}:#{third_note.updated_at}:") + end + + context 'when discussion is resolved' do + before do + subject.resolve!(first_note.author) + end + + it 'returns the cache key with resolved at' do + expect(subject.cache_key).to eq("#{described_class::CACHE_VERSION}:#{third_note.latest_cached_markdown_version}:#{subject.id}:#{notes_sha}:#{third_note.updated_at}:#{subject.resolved_at}") + end + end + end end |