diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2017-11-06 16:52:56 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-11-06 16:52:56 +0000 |
commit | bf0331dc72db658b012d58e33ca47da6d8f99d46 (patch) | |
tree | f596c4876cd50bf13afd1f3e60ccd57640b61656 /spec/services/events | |
parent | 34a205b308d80d600c5651cfb9694f978ef01cab (diff) | |
download | gitlab-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.rb | 37 |
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 |