docbrown/spec
Jeremy Friesen c3c884f4d0
Conditional rendering of "Create Post" link (#17076)
* WIP - Conditional rendering of "Create Post" link

This PR builds on the conversation from forem/forem#17056 and moves in a
slightly different direction.

Important in all of this is that the ability to create a post is
enforced on the server.  If the "Create Post" button were to be visible
but the user couldn't create a post when they clicked the button, they
would get an authorization error (or some such response).

This PR posits a different and perhaps competing approach to
forem/forem#16606.  This PR provides a general approach in which we add
class attributes in our HTML erb files.

Note: I have not included Cypress tests as I don't want to yet commit
that time.  I'm also wondering if this is the "right" thing to do.  I
definitely think we want to add some JS tests.  But could we do JS and
unit tests?  (How do we reach consensus regarding our test approach?)

Again, thank you for the conversation and expect an even more "complete"
PR after we have our discussion.

* Extracting AsyncInfo model to ease testing

* Renaming forbidden to visible

* Adding cypress test to assert no 'Create Post'

These are always treacherous.  What happens when we rename the button?
The test will continue to work.

* Apply suggestions from code review

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Switching to pack file for policy

Follows on [Suzanne's comment](https://github.com/forem/forem/pull/17076#issuecomment-1088567286)

* Update app/javascript/packs/applyApplicationPolicyToggles.js

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2022-04-05 12:47:12 -04:00
..
controllers/concerns 15 minute fix: Add default argument to JsonApiSortParam (#13369) 2021-04-14 10:32:07 +07:00
decorators Routine Rubocop fixes (#16838) 2022-03-09 09:32:50 -05:00
factories Award badges for github commits with various milestones (#14381) 2022-03-31 12:46:50 -04:00
fixtures Remove duplicated work display from header / profile work (#14210) 2021-07-30 12:28:40 +02:00
forms Routine Rubocop fixes (#16838) 2022-03-09 09:32:50 -05:00
generator Add service generator (#11265) 2020-11-10 09:09:35 +07:00
helpers Replace listings tag component (#16855) 2022-03-30 16:51:40 +01:00
initializers A suspended user returns 403 instead of 500 (#16408) 2022-02-04 09:42:23 -05:00
lib Profile attribute names should be unique and non-empty (#16396) 2022-04-04 12:14:02 -05:00
liquid_tags OpenGraph fallback for Embeds (merge-by-any-core) (#17001) 2022-04-04 15:31:38 -04:00
mailers "Reply to" and "From" Email addresses for SMTP Configurations (#16499) 2022-02-16 16:14:54 +02:00
models Conditional rendering of "Create Post" link (#17076) 2022-04-05 12:47:12 -04:00
policies Conditional rendering of "Create Post" link (#17076) 2022-04-05 12:47:12 -04:00
queries Fixes a name conflict in Rpush models (#15978) 2022-01-07 09:38:16 -06:00
refinements Update data exporter to handle admin send (#10274) 2020-10-26 18:00:56 -04:00
requests Display analytics up to yesterday instead of today (#17064) 2022-04-04 15:17:32 -04:00
routing Scoping the :listing routes to feature (#16406) 2022-02-04 10:13:56 -05:00
sanitizers Don't sanitize anchor elements with no href (#16667) 2022-02-22 11:27:38 -06:00
serializers Refactoring to add helper method (#16064) 2022-01-12 11:21:44 -05:00
services Fix "current period" admin charts data examples (#17118) 2022-04-05 08:51:36 -05:00
support OpenGraph fallback for Embeds (merge-by-any-core) (#17001) 2022-04-04 15:31:38 -04:00
system Profile attribute names should be unique and non-empty (#16396) 2022-04-04 12:14:02 -05:00
tasks Make home link an admin-customisable navigation link (#16268) 2022-02-01 09:27:09 +00:00
uploaders Remove Remaining logo_svg Code (#16291) 2022-02-22 12:05:16 -07:00
validators Don't raise error when empty community emoji setting submitted (#15723) 2021-12-17 09:29:55 -06:00
view_objects Avoid using robohash for factory generated article cover images (#17024) 2022-03-28 14:01:29 -05:00
views Revert "Added a way to sort comments on an article (#16686)" (#17093) 2022-04-04 08:36:34 -04:00
workers Profile attribute names should be unique and non-empty (#16396) 2022-04-04 12:14:02 -05:00
i18n_spec.rb Show missing translation keys when test fails (#16637) 2022-02-17 16:21:29 -06:00
rails_helper.rb Removing a JS message about connect (#16982) 2022-03-23 12:30:59 -04:00
spec_helper.rb Bump to Rails 7.0.2.2 MVP (#15908) 2022-03-30 15:00:33 -04:00