Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-03-20 11:20:46 +0300
committerJarka Kadlecova <jarka@gitlab.com>2017-03-20 14:45:43 +0300
commitbf41a2e7525cc952686623b508023c169dbdfe2d (patch)
tree54c40265696352d6972989dddd21d46f7c6ed9ae /spec/helpers/todos_helper_spec.rb
parent691402fb2b361ba19db3b8bdf77b75e513883423 (diff)
Todos performance: Include associations in Finder
Diffstat (limited to 'spec/helpers/todos_helper_spec.rb')
-rw-r--r--spec/helpers/todos_helper_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb
index 50060a0925d..21e0e74e008 100644
--- a/spec/helpers/todos_helper_spec.rb
+++ b/spec/helpers/todos_helper_spec.rb
@@ -1,6 +1,40 @@
require "spec_helper"
describe TodosHelper do
+ include GitlabRoutingHelper
+
+ describe '#todo_target_path' do
+ let(:project) { create(:project) }
+ let(:merge_request) { create(:merge_request, target_project: project, source_project: project) }
+ let(:issue) { create(:issue, project: project) }
+ let(:note) { create(:note_on_issue, noteable: issue, project: project) }
+
+ let(:mr_todo) { build(:todo, project: project, target: merge_request) }
+ let(:issue_todo) { build(:todo, project: project, target: issue) }
+ let(:note_todo) { build(:todo, project: project, target: issue, note: note) }
+ let(:build_failed_todo) { build(:todo, :build_failed, project: project, target: merge_request) }
+
+ it 'returns correct path to the todo MR' do
+ expect(todo_target_path(mr_todo)).
+ to eq("/#{project.full_path}/merge_requests/#{merge_request.iid}")
+ end
+
+ it 'returns correct path to the todo issue' do
+ expect(todo_target_path(issue_todo)).
+ to eq("/#{project.full_path}/issues/#{issue.iid}")
+ end
+
+ it 'returns correct path to the todo note' do
+ expect(todo_target_path(note_todo)).
+ to eq("/#{project.full_path}/issues/#{issue.iid}#note_#{note.id}")
+ end
+
+ it 'returns correct path to build_todo MR when pipeline failed' do
+ expect(todo_target_path(build_failed_todo)).
+ to eq("/#{project.full_path}/merge_requests/#{merge_request.iid}/pipelines")
+ end
+ end
+
describe '#todo_projects_options' do
let(:projects) { create_list(:empty_project, 3) }
let(:user) { create(:user) }