Commit 9f6299c4 authored by Sean McGivern's avatar Sean McGivern

Merge branch '29534-todos-performance' into 'master'

Improve TODOs performance

See merge request !10004
parents 8f92de7b 398a70f3
...@@ -99,8 +99,7 @@ module TodosHelper ...@@ -99,8 +99,7 @@ module TodosHelper
end end
def todo_projects_options def todo_projects_options
projects = current_user.authorized_projects.sorted_by_activity.non_archived projects = current_user.authorized_projects.sorted_by_activity.non_archived.with_route
projects = projects.includes(:namespace)
projects = projects.map do |project| projects = projects.map do |project|
{ id: project.id, text: project.name_with_namespace } { id: project.id, text: project.name_with_namespace }
......
require "spec_helper"
describe TodosHelper do
describe '#todo_projects_options' do
let(:projects) { create_list(:empty_project, 3) }
let(:user) { create(:user) }
it 'returns users authorised projects in json format' do
projects.first.add_developer(user)
projects.second.add_developer(user)
allow(helper).to receive(:current_user).and_return(user)
expected_results = [
{ 'id' => '', 'text' => 'Any Project' },
{ 'id' => projects.second.id, 'text' => projects.second.name_with_namespace },
{ 'id' => projects.first.id, 'text' => projects.first.name_with_namespace }
]
expect(JSON.parse(helper.todo_projects_options)).to match_array(expected_results)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment