docbrown/app
Jeremy Friesen a40efc6bbd
Refactoring questions asked of user (#15762)
* Refactoring questions asked of user

In this pull request, I'm extracting and normalizing role-based
questions asked of the user.

Prior to this commit, our codebase has asked two very similar questions
of our user model:

- `user.has_role?(:admin)`
- `user.admin?`

In asking `has_role?(:admin)` we are relying on implementation details
of the rolify gem.  In addition, the `has_role?` question asked
throughout controllers or views means that it's harder to create
hieararchies of permissions.

In favoring `user.admin?` as our question, we can use that indirection
as an opportunity to discuss and decide "Should someone with the
`:super_admin` role be `user.admin? == true`?"

The details of this commit is to do three primary things:

1. Ask the `has_role?` questions in "one place" in the code (e.g. the
   `Authorizer` module)
2. Extract the role based questions that are on the `User` model and
   provde backwards compatable delegation.
3. Structure the code so that it's harder to accidentally call
   `user.has_role?` (e.g., make `User#has_role?` and `User#has_any_role?`
   private).

This is related to #15624 and the updates are informed by discussion in
PR #15691.  This commit supplants #15691.

* Refactoring the liquid tag policy tests

* Fixing typo

* Bump for travis
2021-12-21 12:45:12 -05:00
..
assets Add comment notification test to Cypress, including a11y improvements to notification page (#15842) 2021-12-21 15:42:13 +00:00
black_box Make Rubocop happy again (#14729) 2021-09-14 09:15:01 -05:00
components/admin/users Small change to make the tools section of member details mobile friendly. (#15159) 2021-10-22 18:47:20 +02:00
controllers Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
decorators role deprecation cleanup (#15717) 2021-12-09 15:27:45 -06:00
errors Guarding against spam from OAuth Sources (#15404) 2021-11-18 16:26:39 -05:00
forms Using a Form Object that will persist for the Creator Settings Form (#15684) 2021-12-10 17:07:40 +02:00
helpers Escape periods and display the group name properly (#15819) 2021-12-17 17:35:42 -05:00
javascript Bump eslint-config-preact from 1.2.0 to 1.3.0 (#15834) 2021-12-21 14:42:20 +00:00
lib ✂️✂️✂️ Drop PWA (#15781) 2021-12-15 21:25:04 +01:00
liquid_tags Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
mailers ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
models Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
policies Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
queries Renaming constant to reflect intention (#15708) 2021-12-07 16:21:43 -05:00
refinements Drop profile columns from user (#10707) 2020-12-03 08:14:38 +07:00
sanitizers Extracting container for allowed tags & attrs (#15338) 2021-12-16 12:24:45 -05:00
serializers ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
services Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
uploaders Added the logo upload to the admin -> customization -> config -> images section. (#15729) 2021-12-15 14:10:27 -05:00
validators Don't raise error when empty community emoji setting submitted (#15723) 2021-12-17 09:29:55 -06:00
view_objects Upgrade to Ruby 3.0.2 (#12103) 2021-08-25 14:26:33 -04:00
views Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
workers Use the tag_list method, rather than the cached_tag_list attribute (#15638) 2021-12-03 14:47:42 -06:00