Commit 8f0e6dfd authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix-for-page-limiter-counter' into 'master'

Actually increment the PageLimiter counter

See merge request gitlab-org/gitlab!23778
parents eddb1dac 6bb2573f
......@@ -63,6 +63,6 @@ module PageLimiter
controller: params[:controller],
action: params[:action],
bot: dd.bot?
)
).increment
end
end
......@@ -71,19 +71,23 @@ describe PageLimiter do
describe "#default_page_out_of_bounds_response" do
subject { instance.send(:default_page_out_of_bounds_response) }
after do
subject
end
it "returns a bad_request header" do
expect(instance).to receive(:head).with(:bad_request)
subject
end
end
describe "#record_page_limit_interception" do
subject { instance.send(:record_page_limit_interception) }
it "records a metric counter" do
let(:counter) { double("counter", increment: true) }
before do
allow(Gitlab::Metrics).to receive(:counter) { counter }
end
it "creates a metric counter" do
expect(Gitlab::Metrics).to receive(:counter).with(
:gitlab_page_out_of_bounds,
controller: "explore/projects",
......@@ -93,5 +97,11 @@ describe PageLimiter do
subject
end
it "increments the counter" do
expect(counter).to receive(:increment)
subject
end
end
end
......@@ -90,8 +90,12 @@ describe Explore::ProjectsController do
end
describe "metrics recording" do
after do
get endpoint, params: { page: page_limit + 1 }
subject { get endpoint, params: { page: page_limit + 1 } }
let(:counter) { double("counter", increment: true) }
before do
allow(Gitlab::Metrics).to receive(:counter) { counter }
end
it "records the interception" do
......@@ -101,6 +105,8 @@ describe Explore::ProjectsController do
action: endpoint.to_s,
bot: false
)
subject
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