docbrown/lib/tasks
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
..
temporary Remove Hacktoberfest Badge Rake Task (#12495) 2021-02-01 09:59:29 -06:00
add_navigation_links.rake Allow for skipping navigation link creation (#16112) 2022-01-17 17:22:24 -05:00
app_initializer.rake Clean up forem:setup task (#13998) 2021-06-18 09:34:18 +07:00
assets.rake Clear asset and vendor caches on deploy (#13631) 2021-06-02 13:14:59 -04:00
badges.rake Split BadgeRewarder into multiple services (#11902) 2020-12-23 09:55:06 -05:00
cache.rake Revert "Revert "Removed service worker (#12974)" (#13014)" (#13015) 2021-03-17 10:57:56 -04:00
data_updates.rake Delay DUS scripts via WORKERS_DATA_UPDATE_DELAY_SECONDS in rake otherwise default run them immediately (#14166) 2021-07-09 13:26:58 -05:00
e2e_seed.rake Minimal Seed Data for Admin Onboarding (#14385) 2021-07-29 17:08:41 +02:00
fastly.rake [deploy] Feature:Add ENV to Skip Fastly Config Update (#10251) 2020-09-08 13:11:12 -05:00
fetch.rake Remove RssReader (#12169) 2021-01-08 11:45:15 -05:00
forem.rake Create Default Nav Links In New Forem (RFC #237) (#14345) 2021-08-02 12:52:36 -04:00
metrics.rake Rename SiteConfig to Settings::General (#13573) 2021-05-21 14:45:37 +02:00
pages.rake Rubocop: Address Metrics/BlockLength violations (#9246) 2020-07-10 13:53:32 -04:00
post_precompile_assets.rake Removed the autoprefixer-rails deprecated gem (#10017) 2020-08-26 17:38:24 -04:00