diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 21:09:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 21:09:11 +0300 |
commit | 0434f38ef1dce4fe640fe1e4542235746ceb943c (patch) | |
tree | 3affe5902c9da74441dfbf5069f76c023b5cd03a /spec/controllers | |
parent | c27acb1d376f7127cd33eadcc8f5683ed55262bc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/concerns/page_limiter_spec.rb | 20 | ||||
-rw-r--r-- | spec/controllers/explore/projects_controller_spec.rb | 10 |
2 files changed, 23 insertions, 7 deletions
diff --git a/spec/controllers/concerns/page_limiter_spec.rb b/spec/controllers/concerns/page_limiter_spec.rb index 9ac94b7e740..287b62cb66c 100644 --- a/spec/controllers/concerns/page_limiter_spec.rb +++ b/spec/controllers/concerns/page_limiter_spec.rb @@ -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 diff --git a/spec/controllers/explore/projects_controller_spec.rb b/spec/controllers/explore/projects_controller_spec.rb index 6f68de52845..c2cd29eb036 100644 --- a/spec/controllers/explore/projects_controller_spec.rb +++ b/spec/controllers/explore/projects_controller_spec.rb @@ -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 |