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

Render all records allowed by the authorization scope

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Pablo Brasero requested to merge render-scoped-records into master Dec 13, 2019
  • Overview 12
  • Commits 8
  • Pipelines 0
  • Changes 6

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. Apart from that, this PR is mostly me figuring out a way to test this in a disposable way that doesn't affect other specs.

"Mostly", because there's one more thing. While working with this, I came across the tabindex settings on the index page. As they stand at the moment, each row is tabbable, as well as each individual cell inside each row. I understand this is because these are links, but it strikes me as very annoying to navigate. On the example above, you need to tab 5 times per row, and you get the same link for all 5 positions. I don't think this is the way tabindex is supposed to be used.

The reason I made this other change is because it's related: when applying the authorization fix, I had to also make rows tabbable only if they had a link. While changing this, I noticed the other behaviour.

Can someone who knows more about accessibility than me confirm all this?

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: render-scoped-records