Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !1744

Don't delete `/tmp` before generator tests

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Pablo Brasero requested to merge github/fork/pablobm/tmp-deletion-culprit into master Aug 20, 2020
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 1

I think I finally discovered why the directory /tmp was being deleted, a behaviour that has been confusing us lately. (See https://github.com/thoughtbot/administrate/pull/1731, https://github.com/thoughtbot/administrate/pull/1726, https://github.com/thoughtbot/administrate/pull/1695).

The issue appears to be with the generator specs. These load this configuration when they run:

https://github.com/thoughtbot/administrate/blob/520a544ae16bcc1c6c4f1fe098a08ec9b90fc1cd/spec/support/generator_spec_helpers.rb#L54-L61

In this code, destination and prepare_destination are helpers provided by Rails to assist when testing generators. See https://api.rubyonrails.org/v3.2.2/classes/Rails/Generators/TestCase.html

Turns out that prepare_destination prepares the destination by... rimraffing it. See: https://github.com/rails/rails/blob/557014d45aeed82ed1e79b83ab59697392a1a5de/railties/lib/rails/generators/test_case.rb#L235

So if we set /tmp as destination, it will be destroyed ahead of each generator spec example.

To fix this, I'm telling it to use a specific subdirectory that can be deleted at will, avoiding further harm.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/pablobm/tmp-deletion-culprit