Commit e30e7f47 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'leaky-constant-fix-3' into 'master'

Add class stub in query limit helper spec

See merge request gitlab-org/gitlab!31949
parents 4d4ebb3b f3c0c515
...@@ -369,7 +369,6 @@ RSpec/LeakyConstantDeclaration: ...@@ -369,7 +369,6 @@ RSpec/LeakyConstantDeclaration:
- 'spec/services/clusters/applications/check_installation_progress_service_spec.rb' - 'spec/services/clusters/applications/check_installation_progress_service_spec.rb'
- 'spec/services/clusters/applications/check_uninstall_progress_service_spec.rb' - 'spec/services/clusters/applications/check_uninstall_progress_service_spec.rb'
- 'spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb' - 'spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb'
- 'spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb'
RSpec/EmptyLineAfterHook: RSpec/EmptyLineAfterHook:
Enabled: false Enabled: false
......
---
title: Add class stubs and fix leaky constant alert in query limit helper spec
merge_request: 31949
author: Rajendra Kadam
type: fixed
...@@ -3,16 +3,21 @@ ...@@ -3,16 +3,21 @@
require 'spec_helper' require 'spec_helper'
describe ExceedQueryLimitHelpers do describe ExceedQueryLimitHelpers do
class TestQueries < ActiveRecord::Base before do
self.table_name = 'schema_migrations' stub_const('TestQueries', Class.new(ActiveRecord::Base))
end stub_const('TestMatcher', Class.new)
TestQueries.class_eval do
self.table_name = 'schema_migrations'
end
class TestMatcher TestMatcher.class_eval do
include ExceedQueryLimitHelpers include ExceedQueryLimitHelpers
def expected def expected
ActiveRecord::QueryRecorder.new do ActiveRecord::QueryRecorder.new do
2.times { TestQueries.count } 2.times { TestQueries.count }
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment