summaryrefslogtreecommitdiff
path: root/spec/services/events
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2017-11-06 16:52:56 +0000
committerDouwe Maan <douwe@gitlab.com>2017-11-06 16:52:56 +0000
commitbf0331dc72db658b012d58e33ca47da6d8f99d46 (patch)
treef596c4876cd50bf13afd1f3e60ccd57640b61656 /spec/services/events
parent34a205b308d80d600c5651cfb9694f978ef01cab (diff)
downloadgitlab-ce-bf0331dc72db658b012d58e33ca47da6d8f99d46.tar.gz
Resolve "DashboardController#activity.json is slow due to SQL"
Diffstat (limited to 'spec/services/events')
-rw-r--r--spec/services/events/render_service_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/services/events/render_service_spec.rb b/spec/services/events/render_service_spec.rb
new file mode 100644
index 00000000000..b4a4a44d07b
--- /dev/null
+++ b/spec/services/events/render_service_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper'
+
+describe Events::RenderService do
+ describe '#execute' do
+ let!(:note) { build(:note) }
+ let!(:event) { build(:event, target: note, project: note.project) }
+ let!(:user) { build(:user) }
+
+ context 'when the request format is atom' do
+ it 'renders the note inside events' do
+ expect(Banzai::ObjectRenderer).to receive(:new)
+ .with(event.project, user,
+ only_path: false,
+ xhtml: true)
+ .and_call_original
+
+ expect_any_instance_of(Banzai::ObjectRenderer)
+ .to receive(:render).with([note], :note)
+
+ described_class.new(user).execute([event], atom_request: true)
+ end
+ end
+
+ context 'when the request format is not atom' do
+ it 'renders the note inside events' do
+ expect(Banzai::ObjectRenderer).to receive(:new)
+ .with(event.project, user, {})
+ .and_call_original
+
+ expect_any_instance_of(Banzai::ObjectRenderer)
+ .to receive(:render).with([note], :note)
+
+ described_class.new(user).execute([event], atom_request: false)
+ end
+ end
+ end
+end