From 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 18 Jun 2020 11:18:50 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-1-stable-ee --- spec/lib/peek/views/bullet_detailed_spec.rb | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 spec/lib/peek/views/bullet_detailed_spec.rb (limited to 'spec/lib/peek/views/bullet_detailed_spec.rb') diff --git a/spec/lib/peek/views/bullet_detailed_spec.rb b/spec/lib/peek/views/bullet_detailed_spec.rb new file mode 100644 index 00000000000..a482cadc7db --- /dev/null +++ b/spec/lib/peek/views/bullet_detailed_spec.rb @@ -0,0 +1,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 -- cgit v1.2.3