Commit graph

22 commits

Author SHA1 Message Date
Fernando Valverde
6e6c32e92a
Fixes a name conflict in Rpush models (#15978)
* Fixes a name conflict in Rpush models

* Removes unnecessary operator

* Review feedback
2022-01-07 09:38:16 -06:00
Fernando Valverde
e45b6c5ab2
Adds validations to avoid creating unnecessary PNs (#14621)
* Adds validations to avoid creating unnecessary PNs

* Fix conditional + add tests

* Trigger CI

* Trigger CI

* Add missing rpush mock in spec

* Mock before testing d'oh

* Extend ability to mock rpush in helpers

* Remove unnecessary user3 from spec
2021-08-31 15:00:30 -06:00
Fernando Valverde
f34b2203d3
Make Consumer Apps dictate aasa results (#14015)
* Makes Consumer Apps dictate aasa results

* progress with ConsumerApp query

* Adds Team ID migration + Stimulus consumer_app_controller.js

* Adds cypress tests

* Adds Backfill data_update_script + more specs & tweaks

* Remove file added by mistake

* Comment typo

* Small tweaks + improved specs

* Update lib/data_update_scripts/20210622145212_backfill_forem_consumer_app_team_id.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update spec/lib/data_update_scripts/backfill_forem_consumer_app_team_id_spec.rb

Co-authored-by: rhymes <github@rhymes.dev>

* Make use of create! and log errors to ForemStatsClient

* Fix specs

* Add mock_rpush call as suggested in review

* Add Review suggestions

* Fix tests

* Remove redundant assert in spec

Co-authored-by: Jamie Gaskins <jamie@forem.com>
Co-authored-by: rhymes <github@rhymes.dev>
2021-06-24 08:36:11 -06:00
rhymes
cf9f6094cd
Have specs run without Redis and refactor ConsumerApp and Device (#13647)
* Add fakeredis gem

* Mock Pusher::PushNotifications in specs

* Remove Redis from Travis

* Add Android tests to ConsumerApp specs

* Use mock for push notification tests and refactor ConsumerApp and Device code

* Fix remaining broken specs

* Use symbols

* Cleanup rpush helpers

* Pusher::PushNotifications is no more

* Use human friendly platform in Admin::ConsumerApps index page
2021-05-07 08:03:16 +02:00
rhymes
9e4de49b79
[Hotfix] [Search 2.0] Optimize performance of listings and articles and fix bugs (#13577)
* Add tsvector index on listings

* Fix sorting order when fetching tag flares

* Add published_at as a sorting condition for Homepage::ArticlesQuery

* Re-added param needed by ES, this got lost somewhere down the line
2021-04-29 17:37:59 +02:00
rhymes
8762815709
[Search 2.0] Match both word boundaries when filtering tags (#13554) 2021-04-28 11:24:45 +02:00
rhymes
f48cf141a6
Use regexp operator to avoid matching partial tags (#13547) 2021-04-27 20:27:11 +02:00
Daniel Uber
0969e8edb4
Remove assert order not called instead of expecting id order (#13544)
We can't rely on the database returning published articles in ID
order, since there are indexes on published_at and on published which
could very well be in any order (btree), and no explicit `ORDER BY id
ASC` was in the query.

I checked the query that's run in the test against blazer, and confirmed that under
real conditions the results are pretty far from ordered:

```
SELECT articles.id FROM articles WHERE (published_at <= '2021-04-27') AND articles.published = true LIMIT 10 OFFSET 0;
----
 id
166916
637099
132444
431420
501939
141182
565391
515964
146231
677241
```

Change the expectation to assert Article does not receive :order, and
remove the expectation that the ids are returned in the order created.
2021-04-27 13:15:56 -05:00
rhymes
8a55c3e888
[Search 2.0] Add query filters for profile, organization and tag index pages (#13510)
* Re-order test cases to increase tests readability

* Add user_id filter for articles query

* Add organization_id and tags filters

* Add new params to SearchController#feed_content

* Add current_user param so that it can be tested for a small pool of users
2021-04-27 08:49:47 +02:00
Fernando Valverde
e602d50d32
Push Notification multi app support (#13304)
* PushNotificationTarget model + /admin/push_notifications (index)

* Admin panel CRUD + request tests

* Migrate Redis backed Rpush model responsibilities into PushNotificationTarget

* Fix failing specs

* Fix conflicts + clean up test by using constant reference

* Removed unused policy

* policy + services + misc feedback

* PushNotificationTarget refactored to AppIntegration

* Review feedback

* Some small cleanup

* Refactor AppIntegration -> ConsumerApp

* Fixing specs

* Trigger Travis

* More naming refactor changes

* Refactor services into queries

* Revert to where(...).first, fix typo and tests

* Apply suggestions from code review

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

* PR review feedback - create_or_find_by, validations, renaming + more tests

* Fix aria-label text

* Remove unnecessary individual index - composite index will do

Co-authored-by: rhymes <rhymes@hey.com>
2021-04-21 17:13:01 -06:00
rhymes
14d98fc590
[Search 2.0] Homepage query (#13339)
* Added basic homepage query object

* Add serializers and initial service object

* Add flare tags, select only required columns

* Test default Homepage::FetchArticles behind a feature flag

* Add all needed params for the homepage feeds

* Add Homepage::ArticlesQuery specs

* Add Homepage::FetchTagFlares specs

* Add Homepage::FetchArticles specs

* Add approved filter to Homepage::ArticlesQuery

* Add specs for SearchController

* Addressed feedback

* Apply PR feedback to cleanup SearchController#feed_content

* Update app/services/homepage/fetch_tag_flares.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update spec/queries/homepage/articles_query_spec.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Update spec/queries/homepage/articles_query_spec.rb

Co-authored-by: Jamie Gaskins <jamie@forem.com>

* Apply PR feedback

* Modify travis

* Revert "Modify travis"

This reverts commit b42548e866804af69542602556db47d37a31034e.

Co-authored-by: Jamie Gaskins <jamie@forem.com>
Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2021-04-21 12:41:24 +02:00
Julianna Tetreault
849bb846ac
[15-Minute Fix] Sidebar Tags Show Relevant Posts on Homepage (#13326)
* Revert change to options hash within Articles::ActiveThreadsQuery#call
  - Reverts double splat change back to options hash
  - Reverts changes to active_threads_query_spec.rb options

* Adds another check for tags to Articles::ActiveThreadsQuery#call
  - Adds a .tags.present? check to #call
  - Removes redundant and broken relation from #call

* Reverts change to options hash within _sidebar_additional.html.erb

* Removes before block from active_threads_query_spec

* Moves tag filter before conditional in Articles::ActiveThreadsQuery#call
  - Adds before block back to active_threads_query_spec for proper
  testing of filtering of tags within spec

* Adjust options to use new kwargs in Articles::ActiveThreadsQuery
  - Adjust active_threads_query_spec to use new args
  - Remove useless code from Articles::ActiveThreadsQuery

* Adjust published_at in else block
2021-04-09 10:40:09 -06:00
Mac Siri
aed41c3238
Fix Ruby 2.7 kwargs' warnings & misc spec warnings (#13256) 2021-04-06 16:57:59 -04: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
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
Ben Halpern
0e712f77b0
Add all new functionality for trusted (#10816) 2020-10-15 17:00:49 -04:00
Diogo Osório
3bc51a13cc
Fixes 500 error when viewing the "Tag Mods" page without having the role on the database (#10515)
* Makes the ModeratorsQuery not return an exception on invalid role

The current implementation of the query would yield an exception when
recieving an invalid state parameter. As per the [GH issue
discussion](https://github.com/forem/forem/issues/10060#issuecomment-692295217),
Zhao recommended to change its behaviour and not trigger an exception in
this condition.

This commit does just that. If the state argument is invalid, the query
now returns an empty result set.

* Adds a warning when there are no matching mods

* Re-trigger the build
2020-10-01 12:55:25 -06:00
Josh Puetz
1c566e0ec4
[deploy] Move /internal to `/admin (#9639)
* First draft - all the big changes

* Changing some more references to 'internal'

* Relocate internal request tests to admin

* Relocate internal system tests to admin

* Fix trailing space

* Test fix

* Move queries from internal to admin

* Docs updates

* Rename internal stimuls controllers to admin (plus docs)

* Rename admin layout

* Fix routing after rebase

* Fixes for latest added admin interfaces

* Serviceworker ignore paths
2020-08-07 10:36:26 -04:00
Molly Struve
b40af82b66
Flaky Spec Fix:Remove let_it_be Test Prof Helper (#9556)
* Flaky Spec Fix:Remove let_it_be Test Prof Helper

* Spec cleanup and fixes
2020-07-29 11:31:01 +02:00
Molly Struve
dd7f51f7fa
Limit the Number of API Keys a User Can Have (#7870)
* Limit the Number of API Keys a User Can Have

* tweak error message and throw in flaky spec fix
2020-05-15 11:33:02 +02:00
Guilherme Vinicius Moreira
31c0b388e5
Refactor internal users index (#7457)
* Refactor internal users index

* Add table-hover to users table

* Add users query spec
2020-04-24 17:27:07 -04:00
Guilherme Vinicius Moreira
806075dbe7
Refactor internal mods page (#7002)
* Refactor internal mods page

* Refactor code style suggestions
2020-04-03 10:41:09 -04:00