diff options
author | Sean McGivern <sean@gitlab.com> | 2018-10-04 11:44:30 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-10-04 12:40:16 +0300 |
commit | 36a7344901b0caa47083d3685e6044d68cd39c34 (patch) | |
tree | f5525ac2228285dbb1926d9820a2f83fa02b28d2 /spec/finders | |
parent | 89b06a7020473f6ac24b6947fcaa8bf6154a1e0b (diff) |
Allow Gitaly N+1s in MR finder spec
These can be triggered by project creation in the setup phase if a spec uses the
RequestStore, but we really don't care about that - it's not an N+1, it's just
several projects being created!
Diffstat (limited to 'spec/finders')
-rw-r--r-- | spec/finders/merge_requests_finder_spec.rb | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb index 33d01697c75..ff4c6b8dd42 100644 --- a/spec/finders/merge_requests_finder_spec.rb +++ b/spec/finders/merge_requests_finder_spec.rb @@ -3,21 +3,37 @@ require 'spec_helper' describe MergeRequestsFinder do include ProjectForksHelper + # We need to explicitly permit Gitaly N+1s because of the specs that use + # :request_store. Gitaly N+1 detection is only enabled when :request_store is, + # but we don't care about potential N+1s when we're just creating several + # projects in the setup phase. + def create_project_without_n_plus_1(*args) + Gitlab::GitalyClient.allow_n_plus_1_calls do + create(:project, :public, *args) + end + end + let(:user) { create :user } let(:user2) { create :user } let(:group) { create(:group) } let(:subgroup) { create(:group, parent: group) } - let(:project1) { create(:project, :public, group: group) } - let(:project2) { fork_project(project1, user) } + let(:project1) { create_project_without_n_plus_1(group: group) } + let(:project2) do + Gitlab::GitalyClient.allow_n_plus_1_calls do + fork_project(project1, user) + end + end let(:project3) do - p = fork_project(project1, user) - p.update!(archived: true) - p + Gitlab::GitalyClient.allow_n_plus_1_calls do + p = fork_project(project1, user) + p.update!(archived: true) + p + end end - let(:project4) { create(:project, :public, group: subgroup) } - let(:project5) { create(:project, :public, group: subgroup) } - let(:project6) { create(:project, :public, group: subgroup) } + let(:project4) { create_project_without_n_plus_1(group: subgroup) } + let(:project5) { create_project_without_n_plus_1(group: subgroup) } + let(:project6) { create_project_without_n_plus_1(group: subgroup) } let!(:merge_request1) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1) } let!(:merge_request2) { create(:merge_request, :conflict, author: user, source_project: project2, target_project: project1, state: 'closed') } |