Skip to content

Clean tmpdirs in metrics endpoint specs

What does this MR do?

This MR tweaks the metrics controller specs to cleanup created temporary directories by using Dir.mktmpdir in around.

Before

Running rspec spec/controllers/metrics_controller_spec.rb left some stray directories in /tmp:

$ rspec spec/controllers/metrics_controller_spec.rb

...

$ ls -ald /tmp/d*
drwx------ 2 peter peter 4096 Aug  6 15:48 /tmp/d20190806-16684-16gyehr
drwx------ 2 peter peter 4096 Aug  6 15:48 /tmp/d20190806-16684-176a0zk
drwx------ 2 peter peter 4096 Aug  6 15:48 /tmp/d20190806-16684-18ccy09
drwx------ 2 peter peter 4096 Aug  6 15:48 /tmp/d20190806-16684-1vxa1dq
drwx------ 2 peter peter 4096 Aug  6 15:48 /tmp/d20190806-16684-p0fs7b

After

$ rspec spec/controllers/metrics_controller_spec.rb

...

$ ls -ald /tmp/d*
ls: cannot access '/tmp/d*': No such file or directory

Does this MR meet the acceptance criteria?

Conformity

Performance and testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes #33401 (closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports