Commit 6bb2573f authored by Robert May's avatar Robert May Committed by Rémy Coutable

Actually increment the PageLimiter counter

parent a033ad83
......@@ -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