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
  • !966

No dashboard generation when NameError #960

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Carl Reyes requested to merge github/fork/das3in/guard-against-uninitialized-model into main Aug 26, 2017
  • Overview 4
  • Commits 1
  • Pipelines 1
  • Changes 2

When using the rails g administrate:dashboard generator with an uninitialized model name, the method will raise a NameError but the app/dashboards/#{foo}_dashboard.rb file will be created regardless. This happens because the generator uses the built-in file_name parameter to create the file name regardless of whether or not the rest of the generator runs.

To solve this, we simply check whether or not klass is truthy before actually generating the file because this is the same guard that we use for the rest of the generator.

I did have a problem writing the test case for this. I expect the run_generator method to raise and expect the file to not exist. It's interesting because... it definitely does raise a NameError but it raises before the test expectations happen. Could use some direction there

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/das3in/guard-against-uninitialized-model