blob: a482cadc7dbb236c55507c8efb16dfe7a21e72d9 (
plain)
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 'spec_helper'
describe Peek::Views::BulletDetailed do
subject { described_class.new }
before do
allow(Bullet).to receive(:enable?).and_return(bullet_enabled)
end
context 'bullet disabled' do
let(:bullet_enabled) { false }
it 'returns empty results' do
expect(subject.results).to eq({})
end
end
context 'bullet enabled' do
let(:bullet_enabled) { true }
before do
allow(Bullet).to receive_message_chain(:notification_collector, :collection).and_return(notifications)
end
context 'where there are no notifications' do
let(:notifications) { [] }
it 'returns empty results' do
expect(subject.results).to eq({})
end
end
context 'when notifications exist' do
let(:notifications) do
[
double(title: 'Title 1', body: 'Body 1', body_with_caller: "first\nsecond\n"),
double(title: 'Title 2', body: 'Body 2', body_with_caller: "first\nsecond\n")
]
end
it 'returns empty results' do
expect(subject.key).to eq('bullet')
expect(subject.results[:calls]).to eq(2)
expect(subject.results[:warnings]).to eq([Peek::Views::BulletDetailed::WARNING_MESSAGE])
expect(subject.results[:details]).to eq([
{ notification: 'Title 1: Body 1', backtrace: "first\nsecond\n" },
{ notification: 'Title 2: Body 2', backtrace: "first\nsecond\n" }
])
end
end
end
end
|