docbrown/app/policies
Jeremy Friesen e1a88d6f81
Allow for skipping navigation link creation (#16112)
* Allow for skipping navigation link creation

This commit provides a possible solution for preventing the re-creation
of a navigation link deleted by a Forem creator.

What I need is a discussion around the life-cycle of the application
installation and updates.

In particular, does this provide a robust enough mechanism for resolving
the issue at hand?

_Note: it pains me to ask about a user's role, but this is provided as a
point of discussion and possible implementationi to address the
underlying issue.  But I'm referencing a constant in the Rake task so
hopefully that will help future refactors.  Also, it's one reason I
needed to remove the `private_constant` declaration._

If we accept this code change, a future task is to document the ENV and
behavior.

Closes #15960

**Further considerations**:

- How might we refine this to not be as "role" reliant?
- Could we have a Site::Setting that we enable/disable
  regarding the navigation links?

Regarding QA:

- Start from an empty database
- Run setup
- Verify Navigation Link exists
- Delete Navigation Link
- Run setup again
- Verify Navigation Link exists (because we don't have a user)
- Run seeds
- Delete Navigation Link
- Run setup again
- Verify Navigation Link exists (because we don't have a user)

```shell
$ cd ./path/to/forem/repo

$ rails db:drop db:create db:schema:load

$ bin/setup

$ bin/rails runner "puts NavigationLink.where(url: '/readinglist').exists?"
  => true

$ bin/rails runner "NavigationLink.where(url: '/readinglist').delete_all"

$ bin/rails runner "puts NavigationLink.where(url: '/readinglist').exists?"
  => false

$ bin/setup

$ bin/rails runner "puts NavigationLink.where(url: '/readinglist').exists?"
  => true

$ bin/rails db:seed

$ bin/rails runner "NavigationLink.where(url: '/readinglist').delete_all"

$ bin/rails runner "puts NavigationLink.where(url: '/readinglist').exists?"
  => false

$ bin/setup

$ bin/rails runner "puts NavigationLink.where(url: '/readinglist').exists?"c
  => false
```

* Bump for travis
2022-01-17 17:22:24 -05:00
..
admin_policy.rb Various internal functionality adjustments (#1264) 2018-12-05 13:28:46 -05:00
api_secret_policy.rb Rename unidiomatic methods (#13328) 2021-04-09 10:59:56 -05:00
application_policy.rb small non-views ruby i18n (#16004) 2022-01-11 10:05:18 +07:00
article_policy.rb Fix organization's admin unable to view an article's stats (#14767) 2021-09-21 16:05:34 +01:00
authorizer.rb Allow for skipping navigation link creation (#16112) 2022-01-17 17:22:24 -05:00
comment_policy.rb When a user is blocked from commenting on an article, show correct error message (#15009) 2021-10-14 07:42:08 -06:00
consumer_app_policy.rb Push Notification multi app support (#13304) 2021-04-21 17:13:01 -06:00
discussion_lock_policy.rb Create DiscussionLocks (#13905) 2021-06-10 11:04:33 -04:00
follow_policy.rb Rename unidiomatic methods (#13328) 2021-04-09 10:59:56 -05:00
github_repo_policy.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
html_variant_policy.rb Add below-article html variant (#1669) 2019-01-28 14:31:43 -05:00
image_upload_policy.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
internal_policy.rb Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
liquid_tag_policy.rb small non-views ruby i18n (#16004) 2022-01-11 10:05:18 +07:00
listing_policy.rb Rename unidiomatic methods (#13328) 2021-04-09 10:59:56 -05:00
message_policy.rb Rename unidiomatic methods (#13328) 2021-04-09 10:59:56 -05:00
organization_policy.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
pinned_article_policy.rb Pin posts to feed (#13807) 2021-06-04 10:54:53 +02:00
rating_vote_policy.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
reaction_policy.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
registration_policy.rb Refactor RegistrationsController (#13903) 2021-06-08 17:03:41 -04:00
response_template_policy.rb Rename unidiomatic methods (#13328) 2021-04-09 10:59:56 -05:00
stripe_active_card_policy.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
stripe_subscription_policy.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
tag_policy.rb Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
user_block_policy.rb Rename banned and comment_banned roles (#12270) 2021-04-06 10:12:14 -05:00
user_policy.rb Prevent banished users from updating their profiles (#16122) 2022-01-17 10:54:02 -05:00
video_policy.rb Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00