Commit graph

1093 commits

Author SHA1 Message Date
Anna Buianova
6a69d9bc61
Set config.cache_classes for test env depending on whether Spring is enabled (#16344)
* Set config.cache_classes for test env depending on whether Spring is enabled

* Explain setting config.cache_classes in the test env
2022-01-28 19:19:19 +03:00
Jeremy Friesen
6fb7361552
Extracting listing routes (#16338)
The fundamental goal in this refactor is to make it easier to disable the
Listings feature set.  By extracting a routes file (via the `draw` method [see
implementation details][1]), we can more easily disable those routes _en
masse_.  This "crease in the code" could mean that we wouldn't need to update
the controller action logic.  An update of that logic might mean going into
each controller action related to listing and adding a conditional for render
404 when listing is disabled.

Now, on to why this should work (not I did not open the application and click
around, but instead went with a "let the framework help me" mindset).

I believe that this should work; though there's a caveat†.  Here's why I
believe this will work for extracting the listing routes:

Before making changes I ran the following:

```sh
$ rails routes | sort > original-routes.txt
```

Let's break that down:

- `rails routes` :: renders the routing table for Rails; this is how
  Rails converts routes to the magic of stuff like `article_path(:id)`
- `| sort` :: to sort the results
- `> original-routes.txt` :: to write the results into a file.

Then I made the changes and ran the following:

```sh
$ rails routes | sort > updated-listing-routes.txt
```

And finally, I ran:

```sh
$ diff updated-routes.txt original-routes.txt
```

The results were as follows:

```sh
500c500
<                     api_organization_listings GET      (/locale/:locale)/api/organizations/:organization_username/listings(.:format)          api/v0/organizations#listings {:locale=>nil, :format=>"json", :to=>"organizations#listings"}
---
>                     api_organization_listings GET      (/locale/:locale)/api/organizations/:organization_username/listings(.:format)          api/v0/organizations#listings {:locale=>nil, :format=>"json"}
```

Note the only difference is that the above two lines, one has
`:to=>"organizations#listings"` and the other does not.  However, the
`./spec/requests/api/v0/organizations_spec.rb` exercises the route; so I
assume a hiccup/foible in the route reporting.

There was no difference between the before and after files.

† Caveat: if for some reason the order of the routes mattered, this will
have messed that up.  I don't think that is the case, but we shall see.

Related to forem/rfcs#291 and #16335
2022-01-28 10:49:52 -05:00
Dwight Scott
077ce36fb4
Added search feature to tags index to search all tags (#16292) 2022-01-28 08:00:11 -05:00
Ben Halpern
1ae10d7e6f
Remove hardcoded /badge page that is DEV-only ✂️✂️✂️ (#16303)
* Remove hardcoded /badge page that is DEV-only

* Remove /badge test

* Remove scheduled job
2022-01-27 13:29:05 -05:00
Anna Buianova
3fdb87ee66
Added "Tags" category to search results (#16265)
* Added tag search to nav menu

* Added tag search

* Improved tags search results view

* Removed commented lines from the controller

* Fix specs for Search::Tag

* Prepare for tags search pagination

* Fixed Search::Tag specs

* styling

Co-authored-by: Paweł Ludwiczak <ludwiczakpawel@gmail.com>
2022-01-26 20:51:15 +03:00
Daniel Uber
4b4d8a7234
Ensure arguments to perform_async are json safe (#16285)
* Convert symbol hash keys to strings when calling .perform_async

Fixes a warning from Sidekiq 6.4.0+ about perform_async arguments
which are not equal when passed to perform (`JSON.parse(JSON.dump(arg))`
should equal arg).

This is a safety measure to prevent passing objects (like classes, or
model instances) rather than their representations (like a class name,
or a model's attributes hash).

This warning will be an error in sidekiq 7

* Turn warning into an error in non-production environments

* Use string keys for reaction notification and article fetched

Missed these two on the first pass

* Update example argument hashes for #enqueues_on_correct_queue

Since this calls perform_async under the hood we need to pass json
safe hashes in the test cases as well.

https://github.com/forem/forem/blob/main/spec/workers/shared_examples/enqueues_on_correct_queue.rb

* Convert keys from FollowData#to_h to string before perform_async

I'm not sure enough where else (outside of notification) to_h is being
called, so I'm converting here when building args, rather than in
FollowData#to_h, which might be my next step.

* Let FollowData#to_h return a hash with string keys

Update spec to use string keys as well.

* Make to_h return string keys for ReactionData

Like FollowData, the #to_h method is only used to call
notifications (this is used to enqueue sidekiq jobs).

* Remove a key that was in the hash

Since reaction_data calls to_h, it gets string and not symbol,
keys. Call Hash#except with a key that was actually there.
2022-01-25 18:07:40 -06:00
Ben Halpern
f393de4c21
Feed Experiment round 5: Factor in sum of tag points (#16272)
* Experiment with sum of tag points

* Cast sum of points to integer
2022-01-25 17:08:31 -05:00
yheuhtozr
cae8ea2deb
i18n key updates in app/liquid_tags (#16275) 2022-01-25 11:03:09 +07:00
Fernando Valverde
41e6b7f858
Add host tag in ForemStatsClient (#16237)
* Add host tag in ForemStatsClient

* fix error in host tag
2022-01-21 08:27:42 -06:00
Josh Puetz
4f24c5ff43
Constantize broadcast messages (#16219) 2022-01-20 11:47:01 -06:00
yheuhtozr
53564c2849
app/mailers i18n (#16191)
* app/mailers i18n

* delete ja.yml
2022-01-20 07:33:29 -07:00
yheuhtozr
71b2724faa
app/services i18n (#16189) 2022-01-20 09:25:25 -05:00
yheuhtozr
adc757f5a5
app/validators i18n (#16166) 2022-01-19 05:25:39 -05:00
Jamie Gaskins
ebdaaaf15b
Revert "Support alternate S3 endpoints" (#16173) 2022-01-18 14:11:18 -05:00
Jamie Gaskins
8bdb2b6d8b
Support alternate S3 endpoints (#15445)
* Support alternate S3 endpoints

* Add missing comma

This is why we should use trailing commas

* Provide sample S3 endpoint config

* Comment out S3 image-storage config in .env_sample

See https://github.com/forem/forem/pull/15445#discussion_r754525723
2022-01-18 11:34:42 -05:00
yheuhtozr
617d66c4e5
app/liquid_tags i18n (#16125) 2022-01-18 11:28:38 -05:00
Ben Halpern
8159f4383c
Feed experiment 4: Final order (#16128)
* Feed experiment 4: Final order

* Remove development line

* Fix text in tests

* Fix text in tests

* Switch query to greatest of
2022-01-17 17:05:43 -05:00
Faruk Nasir
c7c83ea84f
Fix: grammatical error (#16127)
* fix: grammatical error

* fix: grammatical error
2022-01-17 07:07:25 -07:00
Michael Kohl
fef3001bfe
Reconfigure session store, upgrade redis-actionpack (#16088) 2022-01-14 11:02:43 -05:00
yheuhtozr
f1c3138839
app/helpers i18n (#16003)
* app/helpers i18n

* tidy key names

* fix keys

* delete ja.yml

* fix spec

* fix spec 2

* fix for PR

* remove one key for PR

* delete ja.yml
2022-01-13 11:46:32 -05:00
Josh Puetz
629c7114da
Login with Google (#15986) 2022-01-13 10:25:52 -06:00
Michael Kohl
681ab3aac2
Enable use_cookies_with_metadata option (#16087) 2022-01-13 10:27:19 -05:00
Michael Kohl
813222a414
Remove explicit Zeitwerk config, require hack (#16086) 2022-01-13 20:56:47 +07:00
Michael Kohl
f471ba9bd6
Don't load ActiveJob railtie (#16074) 2022-01-12 22:29:54 +07:00
Michael Kohl
92b1958181
Remove IE-specific setting (#16073) 2022-01-12 22:16:57 +07:00
Michael Kohl
3a4fce3b88
Enable AR cache versioning (#16043) 2022-01-12 13:21:16 +07:00
Michael Kohl
3143febb4b
Enable safe Rails 6.1 defaults (#16045) 2022-01-12 10:12:51 +07:00
Ben Halpern
294b3471af
Proposing feed experiment 3: More comment count weight (#15993)
* Initial work

* Implement strategy injection into WeightedQueryStrategy

* Modify field_test config and adding variants

* Change orginal to constant and make some other adjustments

* Fix hardcoded test values
2022-01-11 11:05:06 -05:00
yheuhtozr
b120f3a241
app/controllers/api i18n (#16002) 2022-01-11 10:05:54 +07:00
yheuhtozr
d794e70cbc
small non-views ruby i18n (#16004) 2022-01-11 10:05:18 +07:00
Michael Kohl
6c26a8b40e
Update framework defaults (#15988)
* Update framework defaults to 6.0

* Update application.rb
2022-01-10 13:35:28 -05:00
Ben Halpern
c5e57f71b3
Update precision config on field test dashboard (#15947) 2022-01-04 14:06:13 -05:00
Jeremy Friesen
6269aa4108
Proposing a new feed experiment (#15789)
* Proposing a new feed experiment

This commit involves tweaking a few subtle aspects of the challenger:

1) Remove the sort by published date on the relevance score.  The
   articles will now be listed in the order of perceived relevance.
2) Disable a few levers that did little.  There really aren't any
   `articles.featured = true` articles in the database.
3) Gently increase the weight of each comment in a linear manner.
4) Give a little more weight to posts that don't have followed tags.

In addition, it involves renaming the conversions to better convey their
implementation.  This renaming helps create more descriptive labels for
the test results at `/admin/abtests`.

This commit also adds logic to repurpose the AbExperiment feed_strategy
logic; I envision adjusting the weighted feed strategy levers with some
frequency.

Per discussions, I'm also disabling the "not logged in" feed testing.
We'll use the LargeForemExperimental for this.

* Flipping attribute name to positive

Mentally "not disabled" is harder to parse than "enabled".  This change
helps with setting an optimistic attribute.

* Bump for travis

* Bump for travis

* Removing file committed by mistake

* Extracting method
2022-01-03 14:38:14 -05:00
Michael Kohl
466f111712
Remove sign in/up link from navlinks (#15922)
* Remove sign in/up link from navlinks

* Remove translations

* Update spec
2022-01-03 22:20:29 +07:00
Derek Crosson
ae27d15be7
Prevent whitespace unicode characters from being used in article title and tag (#14909)
* test: whitespace unicode characters cannot be used as titles or tags

* feat: add localized error message

* refactor: use localized error message

* fix: whitespace unicode characters cannot be used as titles or tags

* chore: fix locale after merge

* refactor: fix indentation

* Fix spelling of prohibited in method names

Additionally, rubocop removed a redundant user_id validation since
Article belongs to user.

* Fix spelling

Missed one method call on the same line (fixed the first of two
instances needing changes)

* add failing test cases

The reorganization to remove let was due to a limit on nesting rspec
contexts (it inside context inside describe inside describe when
trying to use different titles in let blocks in contexts)

The first test was clarified (the "U+202D" string that looks like the
code for a unicode point is valid, but the character \u202d is
expected to be invalid

The remaining two tests are based on the feedback I'd given in the PR,
failing because we don't assert title is present after removing
unicode whitespace, and we don't actually set the title (gsub is
non-destructive, returning a value).

* Set title to sanitized title

contains_prohibitied_unicode_characters? was using == (which is not a
good match for strings to regexes), use =~ instead

Change invalid example characters in titles from \u202d (bidi override) to
\u200a (hair space)

Assert that the empty title is blank and can't be blank (even though
it contains no prohibitd characters after replacement)

* change the definition of prohibited characters

From the description, it looks like "unicode space characters" was the
desired rejection set. It was unclear what the existing regex was
matching on (I couldn't get the expected examples to match correctly).

Given the intent, I select "unicode space property, except the ascii
space character", which may _also_ be incorrect but passed the tests.

* Remove now-invalid expectation for presence of user id

Since this was redundant (belongs_to user), we no longer will validate
presence of user id, and we should not test for it.

* Only reject bidirectional text controls

The original issue pointed to the BIDI controls as problematic.

While they called out other "whitespace" characters, as we accept a
wider range of input languages, the need to handle non-printing
punctuation (for example a group separating space for some asian
languages).

It's possible a wider list of characters should be added - if that's
the case I suggest this regex and the sanitization be moved to a
standalone class, and each of the recommendations in
https://www.w3.org/TR/unicode-xml/#Charlist be checked for
applicability.

* Check for blank title after sanitizing disallowed characters

Since validate_title modifies the title, and doesn't set error
messages on the model itself, check for non-empty title _after_
potentially removing any disallowed characters.

* Remove invalid characters before validation

Remove the validate_title and contains_prohibited_characters methods,
and center all logic on the remove prohibitied unicode characters
method.

Remove unneeded and unused arguments (input string is always title,
replacement is always removal/empty string).

* handle case when validating null title

If the title's nil, we don't want to call match? since it will fail.

Title will sometimes be nil when validating.

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
Co-authored-by: Dan Uber <dan@forem.com>
2022-01-03 09:37:03 -05:00
yheuhtozr
3acd4e9deb
delete and add back i18n keys (#15905) 2021-12-30 10:12:40 -05:00
Michael Kohl
06d6b68d9d
Remove webhooks and related code (#15827) 2021-12-28 10:56:37 +07:00
dependabot[bot]
2d98e3346b
Bump rubocop from 1.23.0 to 1.24.0 (#15872)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Michael Kohl <me@citizen428.net>
2021-12-27 10:04:59 -05:00
yheuhtozr
5253717797
fix character limits i18n (#15830) 2021-12-21 07:15:21 -05:00
Michael Kohl
872b007c30
Remove Doorkeeper gem (#15749) 2021-12-21 12:29:58 +07:00
yheuhtozr
021ed9708e
restore i18n key _footer.html.erb (#15831) 2021-12-20 16:33:41 -06:00
ludwiczakpawel
d125617e13
CSS Variables cleanup (#15828)
* variables cleanup

* little fix
2021-12-20 15:42:40 +01:00
ludwiczakpawel
9b7503fde3
Update left sidebar links with new Crayons components (#15757)
* update

* hamburger fix

* Update app/views/shared/_hamburger.html.erb

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

* updates

* spec

* social media icons

* reading list counter

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
2021-12-20 08:46:30 +01:00
Jamie Gaskins
329f33448f
Disallow null user agent and obsolete browser (#15817)
We were previously disallowing empty user agents, but we weren't
blocking requests where the User-Agent header wasn't set at all. This
commit blocks those requests.

This commit also blocks Chrome 74. It's a 2.5-year-old version of an
evergreen browser that releases every 6 weeks, so this is clearly a bot
spoofing this header.
2021-12-17 15:02:30 -05:00
Josh Puetz
731849a068
Mobile mention notifications (#15780) 2021-12-16 11:06:54 -06:00
Mac Siri
dfb0d0300c
Monkey-patch instead of forking cypress-rails gem (#15797) 2021-12-16 11:36:45 -05:00
yheuhtozr
65fe8247a6
clean up views i18n entries (#15731)
* clean up views i18n entries

* Update edit.html.erb

* Update edit.html.erb
2021-12-14 09:23:26 +00:00
Jamie Gaskins
e188eac55d
Fix Fastly bot block for Ruby Net::HTTP clients (#15713)
I was using the wrong VCL request property. It's `req.url`, not `req.http.url`.

https://developer.fastly.com/reference/vcl/variables/client-request/req-url/
2021-12-08 12:32:04 -05:00
yheuhtozr
74b065be58
I18nize views misc & non-HTML templates (#15136) 2021-12-08 11:28:16 -05:00
Jeremy Friesen
bd36ed087b
Removing the stackbit integration (#15701)
* Removing the stackbit integration

The feature didn't quite work and Stackbit no longer supports this
integration.

Yes there are a few places where the webhooks has a string of "stackbit"
but I'm hesitant to remove that, as they are the part of the Webhooks
tests.

Closes #15700

* Update lib/data_update_scripts/20211206222716_remove_stackbit_page.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-12-08 10:20:15 -05:00