blob: ad9940a853f7a4716afdc3eb66ceb27e2b111271 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
require 'rails_helper'
describe StatusCacheHydrator do
let(:status) { Fabricate(:status) }
let(:account) { Fabricate(:account) }
describe '#hydrate' do
subject { described_class.new(status).hydrate(account.id) }
let(:compare_to_hash) { InlineRenderer.render(status, account, :status) }
context 'when cache is warm' do
before do
Rails.cache.write("fan-out/#{status.id}", InlineRenderer.render(status, nil, :status))
end
it 'renders the same attributes as a full render' do
expect(subject).to include(compare_to_hash)
end
end
context 'when cache is cold' do
before do
Rails.cache.delete("fan-out/#{status.id}")
end
it 'renders the same attributes as a full render' do
expect(subject).to include(compare_to_hash)
end
end
context 'when account has favourited status' do
before do
FavouriteService.new.call(account, status)
end
it 'renders the same attributes as a full render' do
expect(subject).to include(compare_to_hash)
end
end
context 'when account has reblogged status' do
before do
ReblogService.new.call(account, status)
end
it 'renders the same attributes as a full render' do
expect(subject).to include(compare_to_hash)
end
end
end
end
|