diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2018-11-14 08:07:35 +0300 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2018-12-10 23:34:33 +0300 |
commit | 4f5abe43279e96efde5f8cac66cbff30d8a95f28 (patch) | |
tree | 931664a9662da2de4ce46781d2715f6426afc120 /spec/helpers/events_helper_spec.rb | |
parent | 1297a1bd7dcccaa4e233925c8467c2bbe41a4bf2 (diff) |
Reduce N+1 from Activity Dashboard and Banzai
There is a combination of few strategies implemented here:
1. Few relations were eager loaded
2. Changed few polymorphic routes to specific ones so we don't have to
use `#becomes(Namespace)` which doesn't preserve association cache
Diffstat (limited to 'spec/helpers/events_helper_spec.rb')
-rw-r--r-- | spec/helpers/events_helper_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index 8d0679e5699..3d15306d4d2 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -84,4 +84,36 @@ describe EventsHelper do expect(helper.event_feed_url(event)).to eq(push_event_feed_url(event)) end end + + describe '#event_note_target_url' do + let(:project) { create(:project, :public, :repository) } + let(:event) { create(:event, project: project) } + let(:project_base_url) { namespace_project_url(namespace_id: project.namespace, id: project) } + + subject { helper.event_note_target_url(event) } + + it 'returns a commit note url' do + event.target = create(:note_on_commit, note: '+1 from me') + + expect(subject).to eq("#{project_base_url}/commit/#{event.target.commit_id}#note_#{event.target.id}") + end + + it 'returns a project snippet note url' do + event.target = create(:note, :on_snippet, note: 'keep going') + + expect(subject).to eq("#{project_base_url}/snippets/#{event.note_target.id}#note_#{event.target.id}") + end + + it 'returns a project issue url' do + event.target = create(:note_on_issue, note: 'nice work') + + expect(subject).to eq("#{project_base_url}/issues/#{event.note_target.iid}#note_#{event.target.id}") + end + + it 'returns a merge request url' do + event.target = create(:note_on_merge_request, note: 'LGTM!') + + expect(subject).to eq("#{project_base_url}/merge_requests/#{event.note_target.iid}#note_#{event.target.id}") + end + end end |