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:
authorcharlieablett <cablett@gitlab.com>2019-06-14 01:20:03 +0300
committercharlieablett <cablett@gitlab.com>2019-06-26 02:47:18 +0300
commit426f1c20b19e5bd98ee0ab8bd5f8851b683a79c6 (patch)
tree14dfe36a0f72fa5fee258f7a89f94c74be6720f4 /spec/support/api
parent4633df7b9e756ae50f35246e9ba93e1c3ca1e01a (diff)
Remove N+1 query for project and group boards
- Add test for N+1 queries - Add destroyable lists scope to Board and List - Preload lists for both project and group boards
Diffstat (limited to 'spec/support/api')
-rw-r--r--spec/support/api/boards_shared_examples.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/support/api/boards_shared_examples.rb b/spec/support/api/boards_shared_examples.rb
index 592962ebf7c..3abb5096a7a 100644
--- a/spec/support/api/boards_shared_examples.rb
+++ b/spec/support/api/boards_shared_examples.rb
@@ -14,6 +14,16 @@ shared_examples_for 'group and project boards' do |route_definition, ee = false|
end
end
+ it 'avoids N+1 queries' do
+ pat = create(:personal_access_token, user: user)
+ control = ActiveRecord::QueryRecorder.new { get api(root_url, personal_access_token: pat) }
+
+ create(:milestone, "#{board_parent.class.name.underscore}": board_parent)
+ create(:board, "#{board_parent.class.name.underscore}": board_parent)
+
+ expect { get api(root_url, personal_access_token: pat) }.not_to exceed_query_limit(control)
+ end
+
describe "GET #{route_definition}" do
context "when unauthenticated" do
it "returns authentication error" do