diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-09-14 08:30:11 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-09-14 08:30:11 +0000 |
commit | 3238dc8654949de6ad073ccab2cc61e4da249cd3 (patch) | |
tree | 4fdac5c2bbdb5a4b6f77f055b6498879fb3089a1 /spec/controllers | |
parent | d3b89a407c1fbfc0011acb8724cef08fd755580b (diff) | |
parent | b376e5c80e3dc6f30dfcc06f6a63209381414f89 (diff) | |
download | gitlab-ce-3238dc8654949de6ad073ccab2cc61e4da249cd3.tar.gz |
Merge branch '34510-board-issues-sql-speedup' into 'master'
fix #34510 add association preloading for issue boards
Closes #34510
See merge request gitlab-org/gitlab-ce!14198
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/boards/issues_controller_spec.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/controllers/boards/issues_controller_spec.rb b/spec/controllers/boards/issues_controller_spec.rb index dfa06c78d46..5163099cd98 100644 --- a/spec/controllers/boards/issues_controller_spec.rb +++ b/spec/controllers/boards/issues_controller_spec.rb @@ -45,6 +45,17 @@ describe Boards::IssuesController do expect(parsed_response.length).to eq 2 expect(development.issues.map(&:relative_position)).not_to include(nil) end + + it 'avoids N+1 database queries' do + create(:labeled_issue, project: project, labels: [development]) + control_count = ActiveRecord::QueryRecorder.new { list_issues(user: user, board: board, list: list2) }.count + + # 25 issues is bigger than the page size + # the relative position will ignore the `#make_sure_position_set` queries + create_list(:labeled_issue, 25, project: project, labels: [development], assignees: [johndoe], relative_position: 1) + + expect { list_issues(user: user, board: board, list: list2) }.not_to exceed_query_limit(control_count) + end end context 'with invalid list id' do |