Commit graph

335 commits

Author SHA1 Message Date
Alex
393ba00221
Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606)
* Attempt number 1

* Fix rack_attack specs

* Fix users_searches_users spec

* Fix display_users_search_spec

* Fix comment typo

* Remove search:destroy task from cypress

* Remove port 9300 from gitpod

* Stub response in attack_spec
2021-05-03 11:09:45 -04:00
Andy Zhao
69597a6b7d
Add react and reactjs (#13572) 2021-04-28 16:21:26 -04:00
Josh Puetz
c3174cade8
Push Notification stats instrumentation (#13118) 2021-04-19 09:42:01 -05:00
Mac Siri
e6dcfb62ae
Simplify CarrierWave's local_storage_config (#13379) 2021-04-13 15:36:20 -04:00
Michael Kohl
5406b0576e
Split Settings::Authentication from SiteConfig (#13095)
* Split Settings::Authentication from SiteConfig

* Move specs

* Sort fields

* Update settings usages

* Update recaptcha usages

* Add data update script

* Update spec

* Rename SiteConfigParams concern

* Fixes, new route, new controller

* Controller and service refactoring

* More controller and service updates

* Spec updates

* More spec fixes

* Move file

* Fix FeedbackMessagesController

* Update admin/configs_spec

* Fix remaining specs in admin/configs_spec

* Fix configs API

* Formatting

* Clean up old service object

* Various fixes

* Update DUS

* Add model argument to admin_config_label

* Fix key name

* Fix specs

* Add distinct request caches for settings classes

* Fix e2e tests

* Fix remaining system spec

* Make DUS idempotent

* Move routes block

* Cleanup

* Switch to ActiveSupport::CurrentAttributes

* Pinned rails-settings-cached

* Update e2e test

* Update lib/data_update_scripts/20210316091354_move_authentication_settings.rb

Co-authored-by: rhymes <rhymes@hey.com>

* Add guard to DUS

* Temporarily re-add two SiteConfig fields

* Fix config show view

Co-authored-by: rhymes <rhymes@hey.com>
2021-04-12 09:41:09 +02:00
rhymes
b80d741d6e
[Rails 6.1] Remove superflous initializer (#13332) 2021-04-09 15:13:01 +02:00
Mac Siri
aed41c3238
Fix Ruby 2.7 kwargs' warnings & misc spec warnings (#13256) 2021-04-06 16:57:59 -04:00
Josh Puetz
f6dc638190
Upgrade to Ahoy 2.0.x (#13085)
* First set of changes for Ahoy 2.0

* Fix line length

* Change test

* Remove unused test

* Remove ahoy_messages.opened_at

* Simply digest email sending calculation to not rely on last_opened

* Remove outdated comment

* Fix typo in test

* Rework site config email digest to a single value

* Fix merge duplication

* Remove UTM references from ahoy emails

* Fix credits tests

* Remove UTM from expected email params
2021-04-06 10:12:32 -05:00
Jacob Herrington
a5b2d109d5
Rename banned and comment_banned roles (#12270)
* Rename banned and comment_banned roles

* Add data update script to rename roles containing 'ban'

* Add named error for Suspended users

* Update unidiomatic method names

* Rename misc banned to suspended

* Apply suggestions from code review

Co-authored-by: Michael Kohl <me@citizen428.net>

* Add unit tests for suspended methods

This commit also adds TODO comments for removing banned and
comment_banned from the codebase after data update scripts have
successfully run on all of our Forems.

Co-authored-by: Michael Kohl <me@citizen428.net>
2021-04-06 10:12:14 -05:00
rhymes
b6360fb80c
Upgrade Rails to 6.1.3.1 (#11333)
* Upgrade Rails to 6.1

* Switch to unreleased bullet

* Run rails app:update

* Add deprecation notices after reading changelogs

* Fix app:update error

* Move middleware in the correct place

* Temporarily disable ransack which does not support Rails 6.1

* Remove wrongly merged file

* Re-run spring binstub

* Fix double quotes

* Track ransack branch with Rails 6.1 support

* Fix deprecation

* Switch to Ransack 2.4 which supports Rails 6.1 rc1

* Fix missing default params for the duration substitution

* Fix new behavior of relation.pluck with contradictory queries

* Fix uploaders specs by tracking rspec-rails main repo

* Disable bullet temporarily

* Fix remaining fixture_file_upload usages

* Add default seconds for video article duration

* Trigger Travis CI

* Upgrade Rails to 6.1.0.rc2

* Remove file deleted on master

* Add Rails 6.1 gem to Gemfile

* Trigger Travis CI

* Revert "Disable bullet temporarily"

This reverts commit cee0c2ce61fb72cbc16d52c94b12ee681e873031.

* Fix bullet version

* Upgrade to acts-as-taggable 7 and fix conflict

* Update Gemfile and rspec-* gems

* Fix nokogiri in Gemfile.lock

* Switch to rspec-rails main branch

* Remove leftover vendored cached items

* Fix path for Rails 6.1

* Use latest release of erb_lint

* Re-run rails app:update to incorporate new changes

* Disable erb_lint's ErbSafety checks

* Fix Gemfile.lock and re-add platform specific gems of Nokogiri

* Add mini_portile2 as well

* Fix latest merge conflict by removing now unused faraday_middleware

* Upgrade to Rails 6.1.3.1

* Regenerate Gemfile.lock and vendor/cache

* Add x86_64 linux gem

* Mark spec as flaky

* Revert "Mark spec as flaky"

This reverts commit 3caba94b33645f9b59c84ba78ee8df042fc7aee0.

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2021-04-05 10:39:48 -04:00
Michael Kohl
847d8a8590
Add settings model generator (#13003)
* Add settings model generator

* Obey the CodeClimate overlords

* Update generator

* Update USAGE

* Add Zeitwerk exception
2021-03-19 12:55:31 +01:00
Fernando Valverde
cf3bde4259
Add mobile push notifications to Forem (#12419)
* First commit with iOS PN working

* RPush cleanup worker + unique jobs config

* Remove rpush tables from schema.rb

* PR feedback

* Feature flag and test for route

* Tests and feature flag PushNotification ::Send

* Update app/controllers/devices_controller.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update spec/routing/devices_routes_spec.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update spec/services/push_notifications/send_spec.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* PR feedback

* Set Rpush driver and url

* More PR feedback

* Apply suggestions from code review

Co-authored-by: Jamie Gaskins <jgaskins@gmail.com>

* PR feedback from Rhymes

* Don’t double render

* Sure

Co-authored-by: Josh Puetz <hi@joshpuetz.com>
Co-authored-by: Josh Puetz <josh@dev.to>
Co-authored-by: Michael Kohl <citizen428@dev.to>
Co-authored-by: Jamie Gaskins <jgaskins@gmail.com>
2021-03-12 14:08:18 -06:00
rhymes
b1fab9ce22
Revert "Adopt session cookie configuration for remember me cookie (#12938)" (#12970)
This reverts commit cc2b76f7e4.
2021-03-11 16:25:25 +01:00
Mac Siri
bd8e800b39
Bump imgproxy to 2.0 (#12963) 2021-03-11 08:24:13 -05:00
rhymes
cc2b76f7e4
Adopt session cookie configuration for remember me cookie (#12938) 2021-03-10 10:45:48 -05:00
Michael Kohl
d1d4c00114
Update OmniAuth to 2.0 (#12715)
* Update gems

* Remove Omniauth CVE from bundle-audit ignore list

* Add omniauth-rails_csrf_protection gem

This is recommended in the OmniAuth upgrade guide:
https://github.com/omniauth/omniauth/wiki/Upgrading-to-2.0#rails

* Temporarily bundle Devise from master

* Pin Devise commit in Gemfile

* Fix CSRF cookie workaround

As suggested by @fdoxyz

* Remove CSRF workaround

* Add DataDog counter

* Add request path tag

* Remove rendering of devise shared links

* Remove unused Devise partial
2021-02-25 12:46:13 -06:00
rhymes
351d4f8da7
Fix regression in Honeybadger.config.exceptions.ignore (#12796) 2021-02-23 19:08:29 +01:00
dependabot[bot]
a464f961f3
Bump doorkeeper from 5.4.0 to 5.5.0 (#12742)
* Bump doorkeeper from 5.4.0 to 5.5.0

Bumps [doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) from 5.4.0 to 5.5.0.
- [Release notes](https://github.com/doorkeeper-gem/doorkeeper/releases)
- [Changelog](https://github.com/doorkeeper-gem/doorkeeper/blob/main/CHANGELOG.md)
- [Commits](https://github.com/doorkeeper-gem/doorkeeper/compare/v5.4.0...v5.5.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Update configuration and i18n strings

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: rhymes <rhymes@hey.com>
2021-02-19 17:49:18 +01:00
Molly Struve
2e6397d319
Optimization:Throttle Tag Index Endpoints (#12520) 2021-02-03 11:14:54 -05:00
rhymes
cb43c9f808
Routine rubocop fixes (#12530) 2021-02-03 10:16:19 -05:00
Nick Taylor
a7da74b993
Cleaning Test Runs for End to End (E2E) Tests (#12143)
* Added custom seed task

* Added a test for the initial login for the intial admin of a forem instance.

* Renamed admin login seed data file.

* Pulled functions out of main Cypress plugin file and import them now.

* Added some comments.

* Added a comment about Cypress tasks requiring a return value to be considered successful.

* Moved admin_login_setup seed file to spec folder.

* Made change requests in regards to rake task.

* Fixed reference to SiteConfig

* Created the seeder class to be shared for all seed files.

* Added a missing param to function comment.

* Fixed seeder require in e2e test seed file.

* Fixed seeder require in seeds.rb. Why is Rails.root required?

* Added an environment guard for not being production in the e2e seed task.

* Made seeder require relative.

* Trying something for the Elastic Search issue in CI.

* Revert "Trying something for the Elastic Search issue in CI."

This reverts commit 7cb2a963c8ac1f9242c612a1b9fe8ff814605df6.

* Search indices are now removed via bundle exec rake search:destroy

* Now rake search:destroy is used in the Cypress task for resetting data as well.

* Moved Seeder class to app/lib

* Added cypress-rails

* Got two flows working with db rollbacks.

* Trimmed down the e2e dataset for now.

* Added a custom Cypress command to encompass test setup.

* removed unused e2e rake task

* added some user login/password e2e tests.

* Added a note about Cypress not cleaning cookies, so we do for the moment.

* Removed code no longer required.

* Removed comment in test that is no longer pertinent to the test suite.

* Removed data cleaning plugins as cypress rails gem handles it now.

* Added @citizen428's recommendation got raising an error if trying to seed production.

* Temporarily have paralleziation of e2e tests disabled to figure out cypres-rails/knapsack pro integration.

* Doh! Forgot a semi-colon in the Travis config.

* Added a comment about not integrating cypress-rails/knapsack pro right now.

* Removed knapsack pro npm package for now as we aren't using it.

* Reworded comment about cypress-rails/kanpsackpro.

* Removed seeding for tags to follow for onboarding in e2e seed data.

* Made pree2e script e2e:setup so it only runs explicitly when needed.

* Renamed bin/e2e to bin/e2e-ci.

* Created a new script for local e2e testing.

* Removed RAILS_ENV as it's in the e2e-ci script already.

* Fixed an auto corrected command.

* Fixed wording in e2e script prompt.

* Removed bundle exec rake data_updates:run that I had added. Doesn't appear to be necessary.

* Added missing new lines.

* Renamed e2e seed file and only use that one now. THere are no others.

* Some script cleanup.

* Added a check for the E2E environment so as to not pollute system tests.

* Now e2e test server cleanup occurs when the server shuts down.

* Put puts as this is really just for testing.

* Put environment variable in the proper place for runnning bundle exec.

* Added a check to only run for E2E tests.

* Some bash script formatting.

* Removed copy paste irrelevant comments.

* Updated e2e server shutdown message.

* Now a data-testid attribute is used for finding the user account errors panel.

* Made test selectors ignore casing of text.

* Removed prod paranoia check in e2e seed file.

* Refactored spec to use new cy.loginUser(user) command.

* Update app/lib/seeder.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Fixed flakiness that @aitchiss was experiencing.

* Rubocop fix.

* Due to a Cypress issue, fixing cookie clearing with another tweak.

* Bumped the wait time to 500ms if cookies don't clear.

* Added a 'bundle check' to the bin/e2e script as suggested by @katiedavis.

* Removed some white space

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-01-29 13:34:01 +01:00
Kirk Haines
ed74f2f245
Abstract DatadogStatsClient to ForemStatsClient (#12304)
* This change abstracts the DatadogStatsClient into a ForemStatsClient.
The purpose of this abstraction is to set the foundation for a subsequent PR that will allow one to use New Relic for recording Forem stats, instead of Datadog, if there is a New Relic configuration found.
This specific change creates an abstraction layer that can be built upon, without changing any actual default behavior. All specs still pass.

* Use delegate instead of explicit methods.

* Delegate instead of explicit methods.

* Fix the error.

* Refactor according to the suggestions in the comments.

* Ooops.  Stats work better when all of the code is committed.

* Removing the alias of count to increment since that was done in error.
2021-01-27 11:25:44 -05:00
Fernando Valverde
e6883ea63b
Explicitly adds the unique jobs middleware (#12441) 2021-01-27 08:16:55 -06:00
rhymes
920024fd7c
Fix autoloading deprecation (#12338) 2021-01-20 15:11:46 +01:00
Fernando Valverde
7f3859a8b4
Workaround for Apple auth problems (still in beta) (#12263)
* Workaround for Apple auth problems (still in beta)

* Fix spec
2021-01-14 09:44:56 -06:00
Ridhwana
4549144fbb
Refactor deployed_at and latest_commit_id code (#12224)
* WIP: release footprint in the admin UI

* feat: show the commit ID and the date

* chore: change env optional to empty string

* fix: change the FOREM_BUILD_DATE to RELEASE_FOOTPRINT

* feat: add Not Available as a last option

* test: last deployed time and latest commit id

* feat: update the way we change the env variable!

* fix: we need to set the RELEASE FOOTPRINT so that this clause is not hit - `return path if release_footprint.blank?`

* feat: add a Forem Instance Model

* chore: rename variable

* feat: use the new model that we created

* feat: Update the Forem Instance model to remove Not available from the model method and add it to the view layer

* test: Forem Instance model to return the correct values when present

* feat: use Forem.deployed_at instead of the Application config directly

* chore: remove the initializer

* feat: rename the data keys to reflect what it does

* fix: oops evaluate the var

* refactor: static values that can never change during the lifetime of the app should be constants

* chore: setup the test to have a release footprint before the test gets executed

* chore: remove the methods

* revert to method + cache

* revert to using method

* reset the instance variable
2021-01-13 16:53:59 +02:00
rhymes
e7f9735354
Remove RssReader (#12169)
* Add script to remove feature flag

* Remove :feeds_import feature flag and RssReader and related classes

* Change Feeds::ImportArticlesWorker signature to support Sidekiq Cron serialization

* Replace RssReader::Assembler with Feeds::AssembleArticleMarkdown

* Removing Assembler
2021-01-08 11:45:15 -05:00
Ridhwana
c70140aa14
feat: The RELEASE_FOOTPRINT is the date of the deployment, hence the alternate heroku variable should also be the heroku deploy date. (#12182) 2021-01-08 18:07:47 +02:00
Michael Kohl
f98cfb59d2
Move constant from initializer to app/lib/constants (#12034) 2020-12-26 19:19:09 +01:00
Michael Kohl
bd13d21b4c
Enable paranoid mode for Devise (#11995)
* Enable paranoid mode for Devise

* Remove two specs

These no longer make sense after enabling Devise's paranoid mode.
2020-12-22 13:47:28 +07:00
Fernando Valverde
fcc5c0d2a1
Add Sign in with Apple (#11934)
* Add gem omniauth-apple

* Integrate omniauth-apple

* Integrate callback

* Add fields

* Add tests, fix bugs and make it all work

* Show only enabled providers for the current user

* Add default profile image for Apple

* Remove localhost patch

* Bring over the changed Apple username if the user changes it

* More specs fixed

* Incorporate feedback from PR

* Fix specs

* Simplify code and fix spec

* Fix Broadcast generators to take into account the new provider

* Fix spec

* Generate a truly unique apple_username

* Fix user specs

* Add omniauth-apple-0.0.2 to vendor cache

* Fix merge conflict and spec

* Update VCR fastly sloan cassette

* Revert "Generate a truly unique apple_username"

This reverts commit 2462875575b0bbd6b3c1d56b25afcd3189671608.

* Fix user specs

* Fix specs

* Fix specs

* Hide Connect Apple button behind a feature flag

* Revert "Hide Connect Apple button behind a feature flag"

This reverts commit 105bde0373389a4eb9b6e948f60734c7e0e99cba.

* Fix line lengths

* Fix spec

* ES tag

* CSRF bypass for Apple callback

* custom user_nickname in Apple provider with small tweaks + omniauth-apple bump

* Fixes username specs

* Makes Apple users default image Users::ProfileImageGenerator

* Fallback to mascot_image_url in test environment to avoid breaking Travis

* Fixes Apple CSRF error + makes default nickname more readable

* Trigger Travis

* Better devise config

* Apple SiteConfig entires in /admin/config

* Fixing specs

* Adds beta_access? to Authentication::Providers::Provider

* Fixes specs

* Codeclimate double quote fix in Gemfile

* Fixes /admin/config allowed params & adds feature flag for provider beta_access?

* Remove Enfile & adds temporary docs

* Adds custom apple auth provider settings

* Fix authenticator spec

* Fix configs spec (use last instead of first to avoid apple special case)

* Remove dangling fields from /admin/config

* updates feature flag

* More test fixes

* Hide config behind feature flag too

* omniauth-apple bump

* Takes care of edge case fallback

* Reverse apple_username update

* Adds auth_time to info hash in apple omniauth mock

* Switch to next instead of nesting for feature flag

* Fixes CVE-2015-9284

* Fixes specs after auth providers initiatior refactor from GET to POST

* Spec fixes

* More spec fixes

* Fix Rails codebase reference link

Co-authored-by: rhymes <rhymesete@gmail.com>
Co-authored-by: rhymes <rhymes@hey.com>
2020-12-18 10:22:33 -06:00
rhymes
5e9be0c32d
Disable ActionController auto params wrapping (#11692)
* Disable ActionController auto params wrapping

Rails by default accepts wrapped and unwrapped parameters in JSON requests (with or without a root object), regardless of the fact that the contract with the client requests wrapped parameters or not. This results in unforeseeable bugs when the client sends unwrapped parameters in lieu of wrapped ones.

As undeterministic bugs are a PITA and this is the classic grey area in Rails apps and as the customer facing API is fully documented and the internal can be manually adjusted, we disable this and be done with this odd feature.

https://github.com/forem/forem/issues/11645
https://github.com/forem/forem/pull/11638

* Remove accidentally committed file
2020-12-02 15:17:43 +01:00
Michael Kohl
824e9a13cb
Add service generator (#11265)
* Add service generator

* Finalize service generator

* Add documentation

* Explicitly require rails/generators

* Update Zeitwerk initializer

* Remove explicit require

* Update docs/backend/service-objects.md

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2020-11-10 09:09:35 +07:00
Molly Struve
6f34241c35
Refactor:Enable Datadog When DD_API_KEY is Present (#11278) 2020-11-05 10:50:32 -06:00
Molly Struve
a741dceace
Refactor:Implement Carrierwave Monkeypatch in all Envs (#11233)
* Refactor:Implement Carrierwave Monkeypatch for all Envs

* add a spec for monkey patch
2020-11-03 10:51:53 -06:00
Molly Struve
9cf92d1a9e
Refactor:Remove Unused BufferedArticles Controller (#11193) 2020-10-30 15:24:02 -05:00
Mac Siri
fb67f13573
Refactor CarrierWave configuration (#11006) 2020-10-21 16:47:52 -04:00
Peter Frank
92f6460ce7
[deploy] Remove "mac" from reserved words (#11003)
Special request for a Forem Admin who wants their first name
2020-10-21 15:35:54 -04:00
Ben Halpern
b0be814300
[deploy] Fix email sender and url issues (#10883)
* Fix email sender and url issues

* Add proper tests

* Add tests

* Change DeviseMailer approach

* ZFix devise test
2020-10-19 16:55:40 -04:00
Mac Siri
30fa3b79a3
Default to Imgproxy on Forem-cloud (#10819) 2020-10-14 12:54:59 -04:00
Mac Siri
01414a5120
Refactor carrierwave config (#10756)
* Refactor carrierwave config

* Remove development specific config

* Remove fog att

* Rearrange attempt #2
2020-10-13 14:15:27 -04:00
Mac Siri
e7c1b3e993
Move Imgproxy endpoint config to Images::Optimizer (#10742) 2020-10-09 10:50:30 -04:00
Mac Siri
5893998369
[Deploy] Update Carrierwave's asset_host for Forem cloud (#10488) 2020-10-07 14:17:54 -04:00
Mac Siri
95eaedc4a2
Add additional startup checks for imgproxy (#10681) 2020-10-06 16:18:52 -04:00
Hugo Peixoto
24e9f81f5a
Fix newlines being chomped in RSS import (#10476)
The CustomText converter was monkey patched to fix a bug related to
preserve_tags. Somewhere in that process, remove_inner_newlines was
changed to strip newlines completely, instead of replacing them with a
single space. This restores that functionality.

In development mode, files are not eager loaded. That means that the
converters were not being required, so it was not possible to reproduce
that issue in development mode (since it was falling back to the
original converter, which does not have the bug). This commit also adds
an initializer that requires every converter.
2020-09-29 10:38:36 -04:00
Mac Siri
8d9db4cce1
Update Imgproxy to use predetermined endpoint (#10412) 2020-09-28 18:30:29 -04:00
Fernando Valverde
5d110c6fe0
Fixes Omniauth redirect_uri when SiteConfig.app_domain is updated (#10432)
* Makes Omniauth rely on Proc instead of initializer value for redirect uri

* Adds SiteConfig.app_domain test for OAuth providers callback_url generation

* Fixes protocol mismatch in test

* Fixes URL encoding problem with query params in test
2020-09-24 11:57:51 -06:00
Molly Struve
1a88905465
Refactor:Remove BackupData Table from Postgres (#10422) 2020-09-24 10:09:20 +07:00
Fernando Valverde
779fad25b9
[deploy] Sets Omniauth full_host config to match the environment (#10419)
* Sets Omniauth full_host config to match the environment

* Fixes tests by passing missing params in omniauth env to mocks

* Default param as nil in omniauth mock helpers
2020-09-22 15:47:50 -06:00
Molly Struve
cc694146e6
Optimization:Move Initialization CacheBust to Background Worker (#10311)
* Optimization:Move Initilization CacheBust to Background Worker

* lower cache bust to 5 min and then bust shell version last

* moving back to 10 min after looking at recent deploy data
2020-09-18 11:30:47 -04:00