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

Render all records allowed by the authorization scope

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Pablo Brasero requested to merge github/fork/pablobm/render-scoped-record-2 into master Apr 02, 2020
  • Overview 0
  • Commits 6
  • Pipelines 0
  • Changes 5

A split from https://github.com/thoughtbot/administrate/pull/1494, removing the bits that were resolved at https://github.com/thoughtbot/administrate/pull/1557. Original description follows, with appropriate edits.

Working with Pundit, I was seeing this index page:

Screenshot from 2019-12-13 22-28-37

That was supposed to be 4 records, but they were showing as empty rows. Instead I was expecting to see the following:

Screenshot from 2019-12-13 22-29-10

The issue was that the Pundit scope for the model was returning those records, but the per-resource policy was returning false for show? on each one of them.

This is a bit of an edge case: if the user can't see the resources, surely the scope shouldn't be returning them. Still I can think of a use case where some users can see them listed (with limited information) but can't access the show page (with additional information). In any case, Pundit allows for this, and I think this behaviour is a bug.

The fix itself is just in app/views/administrate/application/_collection.html.erb. The rest of the PR is me figuring out a way to test this in a disposable way that doesn't affect other specs.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/pablobm/render-scoped-record-2