docbrown/lib
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
..
cypress-rails Monkey-patch instead of forking cypress-rails gem (#15797) 2021-12-16 11:36:45 -05:00
data_update_scripts Launch creator Onboarding with the Feature Flag [ To merge only on January 17 ] (#16090) 2022-01-17 16:46:38 +02:00
generators Spelling (#15702) 2021-12-07 06:59:10 -07:00
liquid Remove redundant freeze calls (#14596) 2021-08-26 10:01:08 -04:00
omni_auth/strategies Forem passport (cont) (#14759) 2021-09-30 06:47:45 -06:00
sidekiq Abstract DatadogStatsClient to ForemStatsClient (#12304) 2021-01-27 11:25:44 -05:00
sitemap_generator [deploy] Bug Fix:Monkey Patch Sitemap Generator is lib not config (#10113) 2020-08-31 16:12:11 -05:00
slack/notifier/util Fix link_formatter.rb's lints (#13301) 2021-04-07 14:28:58 -04:00
tasks Allow for skipping navigation link creation (#16112) 2022-01-17 17:22:24 -05:00