summaryrefslogtreecommitdiff
path: root/spec/support/api
diff options
context:
space:
mode:
authorcharlieablett <cablett@gitlab.com>2019-06-14 10:20:03 +1200
committercharlieablett <cablett@gitlab.com>2019-06-26 11:47:18 +1200
commit426f1c20b19e5bd98ee0ab8bd5f8851b683a79c6 (patch)
tree14dfe36a0f72fa5fee258f7a89f94c74be6720f4 /spec/support/api
parent4633df7b9e756ae50f35246e9ba93e1c3ca1e01a (diff)
downloadgitlab-ce-426f1c20b19e5bd98ee0ab8bd5f8851b683a79c6.tar.gz
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