Commit graph

2550 commits

Author SHA1 Message Date
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
Mac Siri
009c14653a
Fix app/services' ruby 2.7 kwargs warnings (#13177) 2021-04-01 18:40:50 -04:00
Jamie Gaskins
9533c77d7f
User#followed_articles->Article.cached_tagged_with (#13174)
* User#followed_articles->Article.cached_tagged_with

This should improve performance on StoriesController#index

* Make cached_* work like their tagged_with cousins

* Swap to `cached_tagged_with_any`

This was using `tagged_with(tags, any: true)` before so this commit
swaps to using a scope that aligns with that method.

* Allow for searching by Tag models

* do the thing

* abracadabra run the build

* Add comment explaining Postgres regex anchors
2021-04-01 16:20:29 -04:00
Jacob Herrington
18ce0c635c
Add endpoint for articles sorted by published date (#13137) 2021-04-01 13:36:36 -05:00
Julianna Tetreault
95571df8b3
[15-Minute Fix] Fix Flaky trusted_user_flags_user_spec (#13224)
* Load a users profile page twice to get spec to pass

* Add TODO in place of Fix me

* Remove superfluous text from comment and trigger CLA
2021-04-01 11:41:28 -06:00
Michael Kohl
28e38cbb7d
Add flag link to profile dropdown view (#12862)
* Add flag link to profile dropdown view

* Add JS for flag button on profile

* Only show flag button to trusted users

* Quick fix for accidental unflagging

This will be more properly addressed in a future refactoring.

* Update reaction specs

* Update spec

* Make flagging togglable

* Make CodeClimate happy

* Revert accidentally changed file

* CodeClimate

* Update app/javascript/profileDropdown/flagButton.js

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Add JSDoc

* Remove second popup

* Refactor and add system spec

* CodeClimate

* Change send to public_send

* Address PR feedback by @aitchiss

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2021-04-01 09:26:43 +00:00
Molly Struve
20c6b39a30
Optimization:Remove Unused Twitter Counts from User (#13196) 2021-03-31 10:57:03 -05:00
Ridhwana
4848a8b2e1
User Settings Step 1: Add user_settings and user_notification_settings tables (rfc#32) (#12768)
* feat: add the two new models users_setting and users_notification_setting

* feat: add the settings and notification_settings table to the schema

* feat: add the user and notification models

* feat: add the user_id foreign key to the model

* chore: sneaky indent

* feat: add some fields from the profile attributes

* Revert "feat: add some fields from the profile attributes"

This reverts commit 376828746ded063a243505d317140fa5339227cf.

* chore: add some profile field attributes

* chore: remove language_settings

* chore: update indent

* chore: remove language_settings

* feat: changes to the tables

* chore:  remove validation in favor of the foreign keys

* chore: add default for editor version

* Address PR review suggestions

* setting_spec.rb needs to be fixed; need help

* Working on PR review comments

* Continue with addressing PR review comments

* Remove normalize_config_values method; pass correct values from forms

* Address Travis failures

* revert some unnecessary changes in spec file

Co-authored-by: Arit Amana <msarit@gmail.com>
2021-03-31 14:37:46 +02:00
Vaidehi Joshi
95055b2a89
Remove pro role + expose analytics to all users via dashboard (#13156)
* Remove pro role on user, expose pro dashboard to all users as analytics

* Remove pro from Elasticsearch mappings

* Update user role docs to use :trusted over :pro

* Remove pro from Role model spec

* Remove more references to pro, as noted by @rhymes
2021-03-30 15:02:18 -07:00
Nick Taylor
871650053c
[15 minute fix] Fixed bug with templates not being inserted for comments. (#13149)
* Fixed bug with templates not being inserted for comments.

* Removed some trailing white space from a heading.

* Added custom Cypress command to create an article.

* Added E2E tests for creating comments on an article.

* Fixed adding a comment issue caused by mention auto-complete.

* Fixed a selector for the E2E tests.

* Removed some unnecessary white space and also making code climate happy.

* Updated E2E test.

* Added a bit more to the E2E tests.

* Now validation for comment doesn't need to loop through textareas.

* Merge remote-tracking branch 'origin/master' into nickytonline/fix-comment-template-insertion-bug

* Removed a similar spec file and added tests to the other file.

* wip

* Fixed bug where a response template could not be submitted.

* Added/updated E2E tests.

* Reverted a small change to condition for showing the combobox popover.

* Undoing some white space changes as not related to PR.

* Trigger Build

* Put back article seed data as it's used in tests outside of comment tests.
2021-03-30 13:02:54 +02:00
Anna Buianova
40b989ca62
Configure badge credits by admins (#13145)
* Added credits_awarded to /admin/badges forms

* Award credits only if badge has them

* Removed information about credits and listings in the new badge email when not needed

* Specs for number of credits awarded for badges

* Added missing newline

* Fix typo

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Improve new_badge_email.text.erb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Fixed number of credits in notification

* Added specs for number of credits in notifications

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2021-03-30 10:58:48 +03:00
Alex
1597318db8
[Search 2.0] Listings (#13133)
* Add PgSearch to Listing model

* Working MVP - pre-optimizations

* Remove includes

* Update search_spec

* Add more specs

* Fix specs

* Refactor filter_by_category

* Update block parameter name

* Add published index to classified_listings table

* Preload user, organization, and listing_category

* Working MVP - pre-optimizations

* Refactor filter_by_category

* Update schema

* Fix schema for real

* Remove constant specs and make them private
2021-03-29 13:22:16 -04:00
Vaidehi Joshi
a5f014f576
[15 Min Fix]: Fix incorrect scope used by metrics:overview rake task (#13138)
* Fix incorrect scope used by metrics:overview rake task

* Add spec for metrics:overview rake task

* Add guard clause to metrics:overview rake task
2021-03-25 17:31:10 -07:00
Fernando Valverde
f0b8754d4f
Feature: Runtime Content Filter (#13007)
* Working version of Runtime Filter with banner behind Feature Flag

* First attempt to add a cypress test

* Adds simplified test

* Cleanup global references

* Add multi-platform e2e test

* Use --runtime-display var with fallback to block

* Update app/assets/javascripts/initializers/runtime.js

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

* Add FeatureFlag stub to fix unrelated specs

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-03-25 12:04:45 -06:00
Andy Zhao
ca265a13be
Fix more button not working after navigating back to the home page (#12612)
* Reinitialize variables in instantclick context

* Refactor and follow instantclick loading pattern elsewhere

* Actually fix conflicts oops

* Add navigation links to e2e seeds

* Add e2e tests for More button with instantclick

* Set element's onclick directly as opposed to use addEventListener

* Remove unnecessary null check

* Check for visibility instead of class list

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

* Chain .should since we can 👍

* Update test and seed data to account for merge

* Use .findAllByLabelText instead of .get

Co-authored-by: Nick Taylor <nick@iamdeveloper.com>

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Nick Taylor <nick@iamdeveloper.com>
2021-03-25 12:48:41 -04:00
Julianna Tetreault
af5a391429
Part 2: Shows Relevant Posts in Homepage Sidebar (#12942) [deploy]
* Adjust active_threads class method to display posts in homepage sidebar

* WIP: add specs around active_threads class method

* Uses newer AR query syntax in Article#active_threads

* WIP: Updates article_spec.rb to get tests passing

* WIP: Adjust test to return articles that dont fall into constraints

* Adjusts spec to update articles properly

* Adjust article.update_columns to match initial article columns

* Extracts .active_threads into a query object and removes class method
 - Removes class method from Article model
 - Removes class method tests from article_spec.rb
 - Adds Articles::ActiveThreadsQuery to app/queries/articles
 - Adds active_threads_query_spec.rb to spec/queries/articles
 - Replaces Article.active_threads with Articles::ActiveThreadsQuery
in _homepage_content.html.erb and _sidebar_activity.html.erb
 - General code clean up

* Rename number to count in Articles::ActiveThreadsQuery

* WIP new specs

* Update spec

* Repleaces let! with before block to appease rubocop

* Refactors Articles::ActiveThreadsQuery#call per PR review suggestion

* Calls Articles::ActiveThreadsQuery within articles_helper instead of view

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2021-03-25 08:03:55 -06:00
rhymes
83852038e4
[Search 2.0] Reading list (#13052)
* Step one in populating the reading list with PG

This first attempt tries to recycle the `Search::ArticleSerializer` which is only
used in input in ES, but we're using it in output in PG.
For this reason it's currently 15.55x times slower

* Serialize only what is requested by the frontend

`Search::ArticleSerializer` which is only used in ES in the indexing step aims
to add as much info as possible for broader purposes, in this case
(with serialization in output) we should aim to save only what's requested from
the frontend.

* Optimize selection of articles columns

* Select only needed columns for users

* Compute total of reading list items

* Attach the basic filtering based on PG on the search controller

* Restructure in methods

* Add tags support

* Use LIKE on articles.cached_tag_list

* Fix tags as nil

* Fix default pagination

* Add optional FTS for reading list

* Reworded the tags comment explaining why

* Add index to reactions.status

* Fix total counter in Preact readingList component

* Fix total count in reading list backend search

* Add GIN index to articles.cached_tag_list

* Add service tests

* Add search request specs

* Added missing early return

* Update spec/requests/search_spec.rb

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>

* Extract MAX_PER_PAGE constant and add comments

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2021-03-24 15:40:00 +01:00
Anna Buianova
aca08cfb11
Added credits_awarded to badges (#13073)
* Added credits_awarded to badges

* Data update script for updating credits_awarded

* Data update script for updating credits_awarded

* Added null: false to badges.credits_awarded
2021-03-24 11:33:58 +03:00
Michael Kohl
7c31a9cc98
Remove buffer gem and related code: step 1 (#12993)
* Remove buffer gem and related code

* Remove more Buffer-related code

* Remove one more Buffer spec

* Remove DUS

* Remove more Buffer code
2021-03-24 09:58:38 +07:00
Daniel Uber
08645c782c
Disable the User Fills Out Comment system spec (#13103)
This one file seems to be associated with segfaults we're observing in
TravisCI.

To narrow down the source of the issue, disable this set of tests. (If
segfaults continue, this was not the cause and should be re-enabled).

Co-authored-by: djuber <djuber@forem.beta-reduction.com>
2021-03-23 15:06:55 -05:00
Daniel Uber
7c45df1d81
Destroy user's sponsorships when destroying the user (#13100)
* Add a failing test

This is failing because sponsorships are not removed by Users::Delete,
and raises a foreign key constraint error because user.destroy tries
to remove a referenced user.

* When destroying a user, destroy associated sponsorships

There is a `belongs_to` relationship in sponsorships, and a has_many
relationship in Organization, this adds a mirror relation on User with
the equivalent dependent destroy rules.

If an organization is removed, all sponsorships belonging to that
organization are removed too, and now, if a user is removed, all
sponsorships created by that user are removed.

Co-authored-by: djuber <djuber@forem.beta-reduction.com>
2021-03-23 13:06:52 -05:00
Jamie Gaskins
68025ae472
Optimize Article.published scope to use an index (#13071)
* Optimize Article.published scope

The index on `articles.published` is not being invoked due to lack of
diversity in the values in that column (it only has 2 possible values
because it's a boolean).

The index on `articles.published_at` is extremely diverse and will be
invoked any time it can reduce the scope of a query by an order of
magnitude or more.

On DEV, this does not change the row count for the scope:

    irb(main):001:0> Article.where(published: true).count == Article.where(published: true).where(Arel.sql("published_at < now()")).count
    => true

The query plan for the `Articles::Feeds::LargeForemExperimental` service
invoked in the `Stories::FeedController#show` endpoint goes from this:

    Planning Time: 0.271 ms
    Execution Time: 329.258 ms

to this:

    Planning Time: 0.330 ms
    Execution Time: 0.468 ms

This is a reduction in query time of 99.7%

* Set published_at in articles factory

An article that is published should always have a `published_at`
timestamp

* Use Time.current for Zonebie

* Add clarifying comment to Article.published scope

* Generate timestamp in Ruby instead of SQL

I think using transactions for specs was interfering with comparing
timestamps generated in SQL, so this commit generates the timestamp in
Ruby.

* Move published_at outside of the transient block

This was causing articles to be marked as `published_at` right now even
if `published_at` was specified in the `FactoryBot.create` call.

* published_at: nil is no longer the factory default

* published_at is no longer nil by default

* published_at is no longer nil by default

* We didn't actually want to clear this published_at

This was intentionally left out to show that published_at does not get
cleared when we flip published true->false.
2021-03-23 13:07:27 -04:00
Ridhwana
c53cfc5951
RFC#50-P4: Feature Flagged Routes and Interaction Design (#12967)
* feat: add the nested sidebar with some elements

* feat: create a tabbed nav item menu

* feat: add the tabbed nav_item partial to the views that need tabbed nav items

* fix: change variable back

* feat: style the sidebar a bit more

* chore: add some more styles

* feat: add a spec for the nested navigational items

* refactor: a more dynamic tabbed admin helper

* feat: add some more nav items

* fix: controller for reports

* refactor: shorthand if statement

* chore: add the whitespace back

* refactor: rubocop fixes

* chore: use any

* chore: remove whitespace

* refactor: rename the variable

* refactor: use a DSL style admin helper

* chore: variable renaming and routes

* rubocop: fixes

* refactor: move files to more apt places

* chore: keep overview as it was previously

* Update app/views/admin/secrets/index.html.erb

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

* Update app/views/admin/shared/_tabbed_navbar.erb

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

* Update app/views/admin/badges/index.html.erb

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

* chore: disable blocklength

* refactor: move the logic to the model instead of in the view

* chore: remove get_ prefix

* chore: move the request mangling to a helper that finds the controller and scope

* Update app/helpers/admin_helper.rb

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

* Update app/helpers/admin_helper.rb

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

* refactor: Address feedback

* oops

* oops use tr

* feat: update specs

* feat: make the navbar a dropdown

* feat: add a cursor pointer to the dropdown

* feat: add the icons which results in changed data structure

* fix: badge achievements

* feat: rename to an html file, show and collapse links + show active links

* chore: rename tabbed view to an html file

* fix: scope should be apps not app

* feat: add icons for the admin menu

* feat: increase the margin left

* feat: move the overview into the feature flag block and add an icon

* chore:remove files

* chore: indent

* feat: update crayons -link to have no text-decoration

* feat: current link for a scope with one controller

* Update app/lib/menu.rb

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

* Update app/models/admin_menu.rb

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

* refactor: we added svg to the builder so remove it from creating the hash

* feat: undo change to crayons and add it to the admin stylesheet

* Update app/views/admin/shared/_nested_sidebar.html.erb

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

* refactor: change to use ul and li's + a button

* chore: add bracket to next line

* feat: add aria-page

* chore: remove brackets

* feat: added focus specifically for the sidebar

* Update app/views/admin/shared/_nested_sidebar.html.erb

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

* chore: remove additional title

* chore: indent

* feat: add a visibilee keyword to the payload and set it to true by default

* feat: move the feature flagged routes into the correct sections

* feat: check if an item is visible before rendering it

* feat: amend the tabbed_navbar to be more accessible and add in visibilty checks

* chore: update comment

* chore: amend the styles

* chore: change url to path

* chore: comment

* test: add more tests

* Update app/assets/stylesheets/admin.scss

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

* Update app/views/admin/shared/_nested_sidebar.html.erb

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

* Update app/views/layouts/admin.html.erb

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

* chore: merge

* feat: use focus for browsers that dont support focus-visible (I'm looking at you Safari) and move it within the crayons-link so we dont see it on mouse click

* WIP: first pass of stimulus controller code

* feat: interaction design

* chore: remove unnecessary condiition

* chore: only add transparent background when not the current link

* Update app/models/admin_menu.rb

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

* feat; comment explaining

* feat: add an id on the button to be clicked

* feat: disable currentNavItem

* chore: remove event params

* chore: update cursor

* feat: (safe fail)
only show the tabbed navbar when the roures contain values form the data structure

* chore: pass events through + tests

* trigger an onload event and test the disabling of the menu item

* refactor: tabbed menu items

* feat: account for the visibility  of the feature flags

* chore: rubocop fixes

* chore: indentation

* feat: some refactors and updates for rubocop

* Update app/javascript/admin/controllers/sidebar_controller.js

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* feat: set to true

Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: rhymes <rhymes@hey.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2021-03-23 11:12:54 +02:00
Michael Kohl
2c1e8443e1
Make definition of new user configurable (#12999)
* Make definition of new user configurable

* Add new user configuration to config admin

* Only decorate on-demand

* Adapt new user logic

* Update app/lib/constants/site_config.rb

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2021-03-23 14:13:06 +07:00
Julianna Tetreault
945f0bebf4
Re-Add Reporter Email Form to /admin/reports (#13011) [deploy]
* Re-add Reporter email form and add heads up banner to admin/reports

* Adjusts spec expectations to read in a nicer way

* Pulls HEREDOCs out into constants and formats email bodys inline
 - Additionally, fixes inconsistent grammar within all email bodies
2021-03-22 08:19:05 -06:00
Vaidehi Joshi
3f6600541e
✂️ Remove the approvals gem ✂️ (#12978)
* Remove approvals fixtures

* Remove approvals initializer

* Remove approvals gem

* Remove approvals step from travis.yml

* Remove approvals from dockerignore and gitignore

* Remove references to approvals gem in docs

* Un-approvals spec/liquid_tags/codepen_tag_spec.rb

* Un-approvals spec/liquid_tags/dotnet_fiddle_tag_spec.rb

* Temporarily skip other approvals tests

We will still need to delete files in /spec/fixtures/approvals after this.

* Revert changes to dotnet_fiddle_tag_spec and codepen_tag_spec, skip those tests instead

* Temporarily skip more approvals based tests

* Attempt at moving html doc inline

* Comment out one more approvals spec

* Update dotnet fiddle and codepen liquid tag specs to not use Approvals

* Update liquid tag specs + system specs to not use Approvals

* Un-approval feed import, github issue, and tweet tag specs

* Re-add .approvals to gitignore and dockerignore

* Use Rspec compound expectations
2021-03-19 13:28:06 -07:00
Fernando Valverde
d6fde3ab89
Change PushNotifications::Send to use user_ids (#13036)
* Changes PushNotifications::Send to use user_ids

* Changes devices#destroy to use unauthenticated_params

* Fix failing spec - new logic reverses order

* Apply suggestions from code review

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

* Only send new_comment PN with Rpush behind FeatureFlag + spec tweak

* Add query order explicitly to avoid flakyness

* Review feedback - remove order clause in query & other tweaks

Co-authored-by: Jamie Gaskins <jgaskins@gmail.com>
2021-03-19 13:50:04 -06:00
Alex
eb741029b7
Use serializer over as_json (#13029) 2021-03-19 11:16:52 -04:00
Daniel Uber
d6b4e83190
When updating article scores, use new score for blackbox (#13009)
Fixes #13008

Add a test case for blackbox stability

This failed as expected on master and passed on this branch, when a
reaction (which would change the article's calculated score during
update) is added, the hotness should be stable, and not modified
during the second call to `#update_score`.
2021-03-18 14:20:27 -05:00
Daniel Uber
195b202d85
Use normal db transactions around tests (#13035)
* Use normal db transactions around tests

An unrelated spec failure was observed when this was run before
another test expecting the seed data to be present. It looks like the
specific pain point in https://github.com/forem/forem/pull/8865 was
around an rss reader spec (which is no longer in use) and I'd like to
try reverting this truncation behavior here.

The minimal failing test case I had on master was this

```
 rspec ./spec/system/dashboards/user_sorts_dashboard_articles_spec.rb:44  ./spec/lib/data_update_scripts/fix_profile_field_edge_cases_spec.rb
```

The find_by(attribute:...) in the edge case spec returned nil (since
there was no such profile field, the table had been truncated). Tests
pass locally so this might be fine to just leave on the defaults (if
that's the case the truncation support added in #8865 can also be
removed, this is the last caller).

* Reenable transactional feeds imports

rhymes pointed out that a second test uses this db_strategy and that's
the successor to the rss_feed_spec.rb that was the initial issue.

Attempt removal of the truncation strategy, and reenable the
transactional tests, for the feeds import.

* Remove database cleaner

Having removed the last use of it (in the feeds import spec) we no
longer need this gem.

* remove spec support for database cleaner
2021-03-18 12:56:55 -05:00
Andy Zhao
8dd65bd0a3
Get the correct episode by finding the given podcast's episodes (#13034)
* Only search for the given podcast's episodes

* Make describe value a bit more readable

* Add podcast episode show spec
2021-03-18 12:02:37 -04:00
rhymes
8b9f2d546c
Use faster serializers for Search::Postgres::Tag (#13022)
* Use faster serializers for Search::Postgres::Tag

* Fix spec
2021-03-18 09:30:56 +01:00
Alex
1e4d4db562
[Search 2.0] Add Search::Postgres::Username behind a feature flag (#12975)
* Add PostgreSQL FTS for usernames

* Change profile_image_90 logic

* Make search_users private

* Add tsvector index on usernames

* Limit the number of search results

* Update index name
2021-03-17 13:45:58 -04:00
Michael Kohl
7c7a8dcd45
Remove experimental /call functionality from Connect ✂️✂️✂️ (#12979)
* Remove Twilio gem

* remove VideoChatsController + views and specs

* Remove /call related code

* Update spec

* More JS cleanup

* Restore wrongly deleted files

* Remove obsolete files

* More cleanup
2021-03-17 17:06:15 +01:00
Nick Taylor
7c1343be9e
Revert "Revert "Removed service worker (#12974)" (#13014)" (#13015)
This reverts commit 2416387fb4.
2021-03-17 10:57:56 -04:00
Daniel Uber
71df6eaddf
Only check cache or database once (#13010)
* Only check cache or database once

Since `@trusted` is a boolean true/false value, we can't use the
`@ivar || value` pattern, and want instead to check if the variable
has been defined.

Fixes #13006

* Add unit test around memoization behavior

In local testing I was able to get this to fail by changing the
2.times block to include `remove_instance_variable(:@trusted)` (so the
`allow...once` check is sufficient to ensure we are not calling the
cache more than once per instance when false).
2021-03-16 18:58:57 -05:00
Molly Struve
2416387fb4
Revert "Removed service worker (#12974)" (#13014)
This reverts commit 4fb6230606.
2021-03-16 18:10:01 -05:00
Nick Taylor
4fb6230606
Removed service worker (#12974) 2021-03-16 15:55:31 -04:00
Daniel Uber
16d17445a5
reenable article rescoring when moderators flag users (#12983)
* Update worker calculation and disable early return

* Enable service tests

This updates the test to look at the individual article scores
changing, rather than the sum of the articles scores changing

The scores lambda was added as a way to observe this eagerly

* Correctly handle raising the score when vomit is cleared

The initial implementation loaded the articles reactions and the
user's reactions in order to rescore. This restores that activity.

It occurs to me that article.reactions.sum(:points) +
user.reactions.sum(:points) feels like something articles should know
how to do, in which case we can move this into article (#rescore!)?
and call that instead of knowing how to handle moderation specially here.

* Move logic to Article#update_score

Having realized "sum of reaction scores" was an Article concern, I
found that we have a worker to score articles that does _exactly_ what
we're doing here.

Let's use that and allow the vomit reaction presence or absence on a
user to automatically affect the article calculations.

This is at least n + 1 and maybe worse.
2021-03-16 14:04:13 -05:00
Arit Amana
04d5ea8e82
Update the UI for Low-Quality-Comments Notice (#12952)
* Implement change for regular comments

* Modify tests and implement for deleted-commentable-comment

* Fix stupid mistake
2021-03-16 09:40:29 -04:00
Josh Puetz
7f164c2da3
Add test for DevicesController (#12985)
* Add test for DevicesController

* Remove defensive calls
2021-03-16 08:33:25 -05:00
Michael Kohl
2513de92fb
Add rate limit for new user comments (#12925)
* Add rate limit for new user comments

* Rename limit, add check to controller

* Add spec

* Fix specs
2021-03-16 08:39:31 +07: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
c0ea4e5878
[Search 2.0] Add Search::Postgres::Tag behind a feature flag (#12937)
* Add Search::Postgres::Tag to retrieve tags for autocompletion

* Add Search::Postgres::Tag in SearchController behind a feature flag

* Update spec/services/search/postgres/tag_spec.rb

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

* Add index to tags.supported

* Fix hotness_score ordering

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-03-11 19:12:30 +01:00
Mac Siri
bd8e800b39
Bump imgproxy to 2.0 (#12963) 2021-03-11 08:24:13 -05:00
Vaidehi Joshi
68831039d1
Limit mentions in comments (#12923)
* Limit number of mentions in a single comment

Ensure that no more than 6 users can be mentioned in a single comment

* Extract max user mentions into constant

* Check mentions but don't process them unnecessarily

* Add error message check to comment spec

* Add MAX_USER_MENTION_LIVE_AT to comments, plus specs

* Bump MAX_USER_MENTIONS to 7 for DEV Top Seven posts

* Add some clarifying comments around MAX_USER_MENTION limit

* Update app/models/comment.rb to use activesupport helper!

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-03-10 11:23:11 -08:00
Anna Buianova
10a02f46d4
Articles update refactoring (#12913)
* Start refactoring articles update

* Articles update refactoring

* Added a couple of tests for Articles::Updater

* Reorganized code in Articles::Updater and ::Attributes a bit

* A couple of more tests for Articles::Attributes

* Reverted changed in the articles_controller

* Edited_at in Articles::Attributes

* Use Articles::Updater in ArticlesController

* Tests for notifications when published/unpublished an article

* Removed old code

* Return result object from Articles::Updater

* Don't reset articles collection when no series was passed

* Fixed sending notifications when published an article the first time

* Fix articles collection when updating

* Fix setting attributes for articles update

* Spec for articles update via api failure

* More tests for Articles::Updater

* More specs for articles updating

* Pass article instead of article_id to articles updater to avoid loading an article twice

* Remove the redundant check in the articles_controller

* Articles::Attributes refactoring
2021-03-10 13:08:36 +03:00
Michael Kohl
667437ebf2
[15-minute fix] Add ThrottledCall to DisplayAdEventsController (#12924)
* Add ThrottledCall to DisplayAdEventsController

* Update old spec
2021-03-09 09:06:11 +07:00
rhymes
576aceab76
[Hotfix] Restore article content in RSS feed (#12935)
When https://github.com/forem/forem/pull/11268 we didn't test it thoroughly and
thus didn't detect that it wasn't working correctly and that it
resulted in an empty string in the `<description>` field.
2021-03-08 14:53:05 +01:00
Ridhwana
4b902b01c0
RFC#50-P2 Restructuring the sidebar to add nested nav items + tabbed nav items (#12886)
* feat: add the nested sidebar with some elements

* feat: create a tabbed nav item menu

* feat: add the tabbed nav_item partial to the views that need tabbed nav items

* fix: change variable back

* feat: style the sidebar a bit more

* chore: add some more styles

* feat: add a spec for the nested navigational items

* refactor: a more dynamic tabbed admin helper

* feat: add some more nav items

* fix: controller for reports

* refactor: shorthand if statement

* chore: add the whitespace back

* refactor: rubocop fixes

* chore: use any

* chore: remove whitespace

* refactor: rename the variable

* refactor: use a DSL style admin helper

* chore: variable renaming and routes

* rubocop: fixes

* refactor: move files to more apt places

* chore: keep overview as it was previously

* Update app/views/admin/secrets/index.html.erb

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

* Update app/views/admin/shared/_tabbed_navbar.erb

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

* Update app/views/admin/badges/index.html.erb

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

* chore: disable blocklength

* refactor: move the logic to the model instead of in the view

* chore: remove get_ prefix

* chore: move the request mangling to a helper that finds the controller and scope

* Update app/helpers/admin_helper.rb

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

* Update app/helpers/admin_helper.rb

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

* refactor: Address feedback

* oops

* oops use tr

* feat: update specs

* fix: badge achievements

Co-authored-by: Michael Kohl <me@citizen428.net>
Co-authored-by: rhymes <rhymes@hey.com>
2021-03-08 13:14:30 +02:00