diff options
author | Stan Hu <stanhu@gmail.com> | 2019-08-15 11:54:42 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-08-15 11:54:42 -0700 |
commit | b288f128fe0ae20b0db43d207fd87df99dbb551f (patch) | |
tree | c4d9cc77343162fb8bda5d0829b7e6fee7ef03a2 | |
parent | cf5d64e25061411e0b28040afcaa08215efb949d (diff) | |
download | gitlab-ce-b288f128fe0ae20b0db43d207fd87df99dbb551f.tar.gz |
Fix failing N+1 spec in spec/requests/api/discussions_spec.rb
This test was failing in EE because the API helper `get()` creates a
personal access token each time it's run. We can avoid that by
pre-creating a personal access token and passing it each time.
-rw-r--r-- | spec/requests/api/discussions_spec.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/spec/requests/api/discussions_spec.rb b/spec/requests/api/discussions_spec.rb index daf75eb82bb..ef09c6effbb 100644 --- a/spec/requests/api/discussions_spec.rb +++ b/spec/requests/api/discussions_spec.rb @@ -17,6 +17,8 @@ describe API::Discussions do let!(:note) { create(:system_note, noteable: merge_request, project: project, note: cross_reference) } let!(:note_metadata) { create(:system_note_metadata, note: note, action: 'cross_reference') } let(:cross_reference) { "test commit #{commit.to_reference(project)}" } + let(:pat) { create(:personal_access_token, user: user) } + let(:url) { "/projects/#{project.id}/merge_requests/#{merge_request.iid}/discussions" } before do @@ -30,7 +32,7 @@ describe API::Discussions do new_note = create(:system_note, noteable: merge_request, project: project, note: new_cross_reference) create(:system_note_metadata, note: new_note, action: 'cross_reference') - get api(url, user) + get api(url, user, personal_access_token: pat) expect(response).to have_gitlab_http_status(200) expect(json_response.count).to eq(1) expect(json_response.first['notes'].count).to eq(1) @@ -45,7 +47,7 @@ describe API::Discussions do expect_any_instance_of(Repository).not_to receive(:find_commit).with(commit.id) control = ActiveRecord::QueryRecorder.new do - get api(url, user) + get api(url, user, personal_access_token: pat) end expect(response).to have_gitlab_http_status(200) @@ -57,7 +59,7 @@ describe API::Discussions do RequestStore.clear! - expect { get api(url, user) }.not_to exceed_query_limit(control) + expect { get api(url, user, personal_access_token: pat) }.not_to exceed_query_limit(control) expect(response).to have_gitlab_http_status(200) end end |