Commit graph

3045 commits

Author SHA1 Message Date
Michael Kohl
6099d3640d
ListingsToolkit refactoring (#16184) 2022-01-21 09:27:10 +07:00
Jeremy Friesen
711f1bb0cd
Let override of ToS and CoC show in onboarding (#16217)
* Let override of ToS and CoC show in onboarding

Prior to this commit any changes to the terms or code of conduct were
not reflected in the onboarding links.

With this commit, I'm leveraging a newly created method that first
checks if there's a page for the given slug.  If there is, use that
page's copy.

To test:

- Overwrite default /terms page on a Forem
- Navigate to /onboarding or sign up as a new user
- Click on Terms of Use link text
- Review Terms of Use

Closes #15296

* Adding spec around not passing a block
2022-01-20 19:45:39 -05:00
Josh Puetz
4f24c5ff43
Constantize broadcast messages (#16219) 2022-01-20 11:47:01 -06:00
Julianna Tetreault
615137a883
Remove the "Getting Started" Section from the Config (#16033)
* Removes the Getting Started section and related code from the config

* Removes the admin_manages_configuration_spec.rb

* Removes "Required" tags from Config

* Reverts removal of activateMissingKeysModal

* Removes mandatory.rb
2022-01-20 07:31:35 -07:00
yheuhtozr
71b2724faa
app/services i18n (#16189) 2022-01-20 09:25:25 -05:00
Arit Amana
ea6bd0f366
Implement Unified Embed for Tweet URLs (#16218)
* building

* complete implementation and add specs
2022-01-20 08:05:56 -05:00
ludwiczakpawel
43c188eafb
Updated indicators (#16190) 2022-01-20 06:25:10 +01:00
Michael Kohl
4f1a5b5a39
Move BlackBox to app/lib (#16183) 2022-01-20 09:37:53 +07:00
Michael Kohl
c8fbc97b60
Re-enable stories specs (#16182)
* Re-enable stories specs

* Travis wake up
2022-01-19 13:14:31 -05:00
Daniel Uber
f2a8cbce7e
Remove "connect" feedback message special treatment (#16167)
* Remove special handling of "connect" feedback by name

The special casing was related to "connect" feedback having both a
reporter and an offender. Check for offender instead.

Additionally, there was special casing in the controller to rate-limit
connect feedback separately from other channels. Since connect doesn't
exist, we should not need this.

There's a small bit of functionality (when I post to feedback_messages, the
number of feedback messages increases) that was removed from the test
case, we can add that back (and "connect" type, and
offender_id attributes) since it looks like it might have been a
useful assertion.

* Add back feedback message controller creates feedback message case

This was removed in the last commit because it was in a "connect" chat
channel context, but the basic "should persist a record" test was
otherwise valid. Submit an abuse-report rather than a connect message
report.

* typo

feeedback, woops.
2022-01-19 08:32:10 -06:00
Jane ♥
d5348995c1
Finishes adding all the codepen embed options available (#16102)
Co-authored-by: JaneOri <7545075+James0x57@users.noreply.github.com>
Co-authored-by: Michael Kohl <me@citizen428.net>
2022-01-19 09:23:15 +07:00
dependabot[bot]
b4b12a993a
Bump rubocop from 1.24.1 to 1.25.0 (#16171)
* Bump rubocop from 1.24.1 to 1.25.0

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.24.1 to 1.25.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.24.1...v1.25.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

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

* Appeasing rubocop

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Friesen <jeremy.n.friesen@gmail.com>
2022-01-18 19:46:42 -05:00
Dwight Scott
9375ba4932
allow approved tags to show articles and not render 404 (#16101) 2022-01-18 13:09:19 -05:00
Daniel Uber
97d62bac69
Move basic feed test for blocked users (#16165) 2022-01-18 10:32:48 -06:00
Jeremy Friesen
5ec47d99dc
Ensuring we don't track views of author or unpublished (#16143)
* Ensuring we don't track views of author or unpublished

Prior to this commit, I was surprised to learn that we:

1) Tracked an author's view of their article.
2) Tracked views of an unpublished article.

This came up from a Forem creator asking if they could reset the view
counter.  Or trigger the reset on publication.

I think a general business logic policy of don't track views for the
author and don't track views for unpublished articles is a reasonable
default.

Were we to pursue the clear views on publication, we'd need to consider
something that went from unpublished -> published -> unpublished ->
published.  Without a more explicit state machine, triggering a
busineiss logic behavior seems a bit unexpected.

In other words, I wrote an article.  There are 20 views when I realize
that I need to unpublished it.  I make the changes in the unpublished
state, and re-publish.  I'd assume that those 20 views would still be
"recorded" and counted towards my article's view counts.

* Adjusting condition structure

Prior to this commit, the `if` clause was rather far to the right.  This
helps make the if clause more pronounced.
2022-01-18 11:23:18 -05:00
Jamie Gaskins
dd8aeee58e
Move work from template to controller (#16092)
* Move work from template to controller

* Render only the final result with the template
2022-01-18 11:21:25 -05:00
Daniel Uber
71dcc7d53f
Move system tests (#16077)
* Move browser based test for article feed into spec/system

* Move user subscription tag system tests to spec/system
2022-01-18 08:08:41 -06: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
Andy Zhao
5b1ca20b16
Prevent banished users from updating their profiles (#16122)
* Don't update social information for suspended/banished accounts

* Prevent suspended users/accounts from updating their profile information

* Add tests and fix some logic
2022-01-17 10:54:02 -05:00
Ridhwana
f3cb4238d2
Launch creator Onboarding with the Feature Flag [ To merge only on January 17 ] (#16090)
* feat: add the DUS script

* feat: enable the Feature Flag
2022-01-17 16:46:38 +02:00
Ridhwana
a8fa1c916a
Creator Onboarding Logo Updates for launch [Will be merged and Deployed 17 January] (#16103)
* feat: hide the logo_svg behaind a featur flag if we've ennabled it

* feat: show the input field iis the feature flag is enabled

* feat: show the new logo when the feature fkag is enabled

* chore: change working

* feat: add a logo spec

* fix: with the updated changes we show a community name if there is no logo, hence we sometimes would need to update the community name instead of the logo on preview

* fix: use innerText

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

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

* empty commiit

* empty commiit

Co-authored-by: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com>
2022-01-17 16:46:06 +02:00
Arit Amana
dba225b1be
Implement Forem Organization Unified Embed (#16110)
* Complete implementation and add specs

* nudge Travis

* Clarify forem_domain use

* Clarify forem_domain use

* More specific check for forem_domain
2022-01-14 13:34:57 -05:00
Arit Amana
0c6ea5d9e9
Complete Implementation and add specs (#16095) 2022-01-14 09:33:35 -05:00
Jeremy Friesen
3253ba2c7a
Patching ERB rendering of the data-info JSON (#16067)
Prior to this commit, we were somewhat naively rendering Hash style data
attributes in our ERB templates.  By rendering each hash attribute
separately, we were rendering characters that could break the
javascript (e.g. double hack or backslash `"` or `\`).

By moving to this view_object rendering, we leverage Rails's `to_json`
behavior to ensure properly escaped values.  As part of this exercise, I
generalized the method to allow for other places to benefit from this
behavior.

This generalization also helps ensure that we have a more conformant
rendering (e.g. we should always have an :id, :className, and :name
value in our data-info hash).

_Note: I've updated the user's names for Cypress tests as they are more
likely to catch the particular issue than anything else.  I assume that
I'm going to break some cypress tests and will need some help fixing
them._

Closes #15916, #14704

Supersedes #15983

How to test locally:

Assuming you have seeded database (e.g. `rails db:seed`), checkout the
"main" branch.  Then in `rails console` find a user that's written articles:

```ruby
user = Article.last.user

user.update(name: "\\: #{user.name}")

user.articles.each(&:save)
```

Now, again on the "main" branch, start your application (e.g.,
`bin/startup`).

Then get a logged in and a logged out browser session going.  Open your
web inspector and open console.  Then go to the local instances homepage
(e.g., http://localhost:3000) and look for JS errors.

On the main branch, you should see an exception around
`JSON.parse(button.data.info)` (assuming that the `user`'s article is
rendered on the homepage).

Then go to the user's page (e.g. https://localhost:3000/:user-slug) and
look for JS parse errors.

On this PR's branch (e.g.,
`jeremyf/take-two-at-resolving-gh-15916`)
you shouldn't see those console errors.

More importantly, the Follow buttons should work.
2022-01-14 08:30:49 -05:00
Michael Kohl
2dc6227b5f
Update crayons_icon_tag helper (#16099) 2022-01-14 17:14:42 +07:00
Jeremy Friesen
f3bc5e5db2
Fixing Rubocop's auto-correct recommendations (#16098)
```shell
$ bundle exec rubocop --auto-correct
```
2022-01-13 21:40:19 -05:00
Andy Zhao
c812e5250f
Convert admin/config text fields with static options to dropdowns (#16094)
* Add validations and constants for feed_style and strategy

* Convert text fields w/ static options to dropdowns

* Convert Bootstrap selectpicker to native HTML select tag

* Update test to use valid feed strategy
2022-01-13 16:15:48 -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
Jeremy Friesen
05bad3ae10
Replacing custom call with existing cached method (#16083)
There's a few things going on:

1. I introduced [a change][1].
2. There was a [data script][2] that should've completed successfully, but
   some data was not converted (see [Blazer query on DEV.to][3])

Thus the current state of the data means that we have have serialized
data in an `OpenStruct` format and `Articles::CachedEntity` format.

This patch should work because the OpenStruct should previously have an
`image_profile_90` attribute.

In addition, I have added some recommendations and tests to better
describe what's happening.

[1]:9780dba380/app/models/articles/cached_entity.rb (L4)
[2]:9780dba380/lib/data_update_scripts/20200723070918_update_articles_cached_entities.rb (L1)
[3]:https://dev.to/admin/blazer/queries/609-serialized-data-in-mixed-forms
2022-01-13 07:48:32 -05:00
Jeremy Friesen
b115b2d17e
Appeasing Rubocop as it sneaks some changes in (#16085)
I was working on another branch and as part of my commit, Rubocop
removed a validation (but not the spec that asserted the validation).

Below is the "non-updating" rubocop offense on the other branch.

```shell
❯ rubocop ./app/models/notification_subscription.rb
Inspecting 1 file
C

Offenses:

app/models/notification_subscription.rb:13:29: C: [Correctable]
Rails/RedundantPresenceValidationOnBelongsTo: Remove explicit presence
validation for notifiable_id.
  validates :notifiable_id, presence: true
                            ^^^^^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense auto-correctable
```

To remediate, I ran:

```shell
> rubocop --only "Rails/RedundantPresenceValidationOnBelongsTo" \
  --auto-correct
```

This resolved the `app/models`.  Then did some regex magic and removed
the assertions from `spec/models`.

For Forem folks, I wrote a [forem.team post][1] discuss if this is how
we want to proceed.

[1]:https://forem.team/jeremy/rubocop-auto-updating-mayhem-33a6
2022-01-13 07:48:01 -05:00
Jeremy Friesen
6929cd908c
Moving from 'should' syntax to 'expect' (#16084)
In Travis I found the following message:

> Using `should` from rspec-expectations' old `:should` syntax without
> explicitly enabling the syntax is deprecated. Use the new `:expect`
> syntax or explicitly enable `:should` with
> `config.expect_with(:rspec) > { |c| c.syntax = :should }`
> instead. Called from
> /home/travis/build/forem/forem/spec/models/html_variant_spec.rb:76:in
> `block (2 levels) in <main>'.
2022-01-13 00:33:42 -05:00
Jeremy Friesen
9780dba380
Adding a convenience/optimiization method. (#16079)
* Adding a convenience/optimiization method.

Without this method, the `@object` will handle the `decorate` message;
which will go through the logic of determining the decorator class, and
isntantiating a new decorator.

Related to but orthogonal to #16078.

* Update app/decorators/application_decorator.rb

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

Co-authored-by: Jamie Gaskins <jamie@forem.com>
2022-01-12 16:28:13 -05:00
Arit Amana
a4f12d39d9
Complete implementation; add specs (#16081) 2022-01-12 15:45:59 -05:00
Jeremy Friesen
a65954107f
Refactoring to add helper method (#16064)
* Refactoring to add helper method

Prior to this commit, we made view level calls to service modules.  This
refactor provides convenience methods on the model.

Furthermore, it addresses a few Rubocop violations that "come along for
the ride."

* Ensuring cached entity squaks like User

* Fixing broken spec

* Fixing typo
2022-01-12 11:21:44 -05:00
Jeremy Friesen
0a1b222bb7
Moving the "Null" user object closer to User (#16070)
* Moving the "Null" user object closer to User

Prior to this commit, we had the presentation concept of a DELETED_USER
in the ApplicationHelper.  Further, we did type checks against that
object instead of relying attributes of the object.

With this commit, I moved the "Null" user closer to the User definition
to help highlight the concept that there might be deleted users.

I didn't remove all of the type checks, but did attempt to create a more
"duck-type" object.

Further, I moved away from an OpenStruct which in the past (and perhaps
present) had performance issues.

* Moving DeletedUser into Users module space
2022-01-12 08:45:01 -05:00
Daniel Uber
fadc84f47e
Add apple_connect welcome notification broadcast (#16063)
* Generator output

Add your logic here!

* replicate the logic from the forem connect migration

* Add data update script

This will generate the expected broadcast message to fix #16059

* Add apple connect to seeds file
2022-01-11 14:34:19 -06:00
Daniel Uber
6a9757c8ef
Modify welcome notification generator to handle errors per-message (#16060)
* Modify welcome notification generator to handle errors per-message

The original flow aborted all processing when any
ActiveRecord::RecordNotFound exception was raised. This causes a
situation where a missing broadcast message (by title) causes that
notification message to fail, and each day the same failure to
occur (since it wasn't successfully sent the day before), blocking all
further messages.

We want these to proceed on the schedule implicit in the checks, and
failing early prevents that.

Modify the error handling to catch RecordNotFound on each message, and
continue throught the checks until a notification is enqueued or all
checks have been attempted.

* Run welcome broadcast check 4 hours after the user was created

This started to fail when I modified the generator (why? because the
user was 7 days old and _other_ notifications would be sent).

Ensure the user is 4 hours old before checking that the disabled
welcome broadcast message is checked, and not sent.
2022-01-11 14:27:21 -06:00
Arit Amana
7dc59eb4bf
Raise Error with Invalid UnifiedEmbed URL (#16051)
* raise error with invalid embed url

* fix spec; update docs
2022-01-11 14:55:06 -05: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
Jeremy Friesen
c5bf4bf880
Extracting duplicate logic (#16035)
Prior to this commit, we had two places that need to know the nuances
ofquerying for tag flares and what we should include in our queries for
serialization.

With this commit, we're factoring towards a common source of knowledge
and providing a much needed test for the expected output of this
serialization.

Loosely related to #15916, #15983, #15994, and #16032.
2022-01-10 15:19:04 -05:00
Jeremy Friesen
b8105661d0
Removing unused Search::ArticleSerializer (#16032)
Below are the grep results of searching for ArticleSerializer (note
there are no remaining `Search::ArticleSerializer' references).

Using `ripgrep` (e.g., `rg`), I have the following from the `main`
branch.

```log
> rg ArticleSerializer
app/services/search/reading_list.rb:
  Search::ReadingListArticleSerializer
app/services/search/article.rb:
  Homepage::ArticleSerializer
app/services/homepage/fetch_articles.rb:
  Homepage::ArticleSerializer
spec/serializers/search/reading_list_article_serializer_spec.rb:
  RSpec.describe Search::ReadingListArticleSerializer do
app/serializers/search/reading_list_article_serializer.rb:
  class ReadingListArticleSerializer < ApplicationSerializer
app/serializers/homepage/article_serializer.rb:
  class ArticleSerializer < ApplicationSerializer
```

Definitely want to keep pruning unused code.

This relates to exploration around #15916 and the attempted solutions in
2022-01-10 13:57:50 -05:00
Julianna Tetreault
0dfad5b07f
Remove Setup Banner (VerifySetupCompleted) (#15969)
* Remove all references to VerifySetupCompleted to remove setup banner

* Removes setup banner-related specs

* Adjusts the title in activateMissingKeysModal

* Adds the show expand classes to getStartedBodyContainer in show.html.erb
2022-01-10 10:30:05 -07:00
Ridhwana
81571bb0b5
Data Update Script to migrate logo_svg contents to png file (Will be merged and deployed on 10/01) (#15710)
* feat/WIP: first version of the svg logo to png logo DUS

* feat: logoSVG Uploader

* refactor: remove the if original_filename

* feat: add a test for the logo_svg_uploader

* feat: update the test and dus

* add soem error handling

* updae the rails spec helper

* feat: provide a content type

* feat: add content type

* Try https://travis-ci.community/t/build-times-out-with-no-apparent-reason/5083/4

* chore: try this suggestion https://stackoverflow.com/questions/41138404/how-to-install-newer-imagemagick-with-webp-support-in-travis-ci-container

* chore: remove libweb adn fix = in the travis.yml

* chore: undo the changes to attempt to update the version for image magick

* feat: install gsfonts for convert

* chore: add a comment for svg

* feat: use the good practices for tempfile, update error handling and update the tests

* chore: update the timestamp on the DUS

* feat: convert to png with a transparent background using Image Magick

* feat: substitute some css variables with real css colors

* chore: revert the path

* fix: set content type

* Update lib/data_update_scripts/20220105112823_migrate_logo_svg_data.rb

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

Co-authored-by: Jamie Gaskins <jamie@forem.com>
2022-01-10 16:09:34 +02:00
Arit Amana
11b7255439
Implement Replit Unified Embed (#15992)
* complete implementation and specs

* add error spec

* write clearer spec
2022-01-07 15:00:06 -05:00
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
Jeremy Friesen
5b10addbb4
Tidying up and documenting Tag model (#15949)
* Tidying up and documenting Tag model

Prior to this commit we had a custom `where(alias_for: [nil, ""])`
call.  That call highlighted that we lacked a term for a Tag that was
not an alias.  As part of this commit, I named that a "concrete" tag.

Further, I added scopes to assist in helping "name" those concepts.

This commit also adds a data migration and utilization of
StringAttributeCleaner to hopefully get away from `alias_for == ""`
situations.

As of writing this commit <2022-01-04 Tue 17:22 UTC>, in DEV.to we had 5
tags with `alias_for == ""`:

- actionshackathon21
- regex
- atlashackathon
- hotwire
- foremfest

In https://dev.to/admin/blazer I ran the following:

```sql
SELECT name FROM tags WHERE alias_for = ''
```

* Renaming concrete to direct
2022-01-07 09:14:31 -05:00
Ben Halpern
723f9f22c0
Fix goal conversion field test typo (#15985)
* Fix goal conversion field test typo

* Fix typo in test too

* Undo testing word change
2022-01-06 16:34:36 -05:00
Arit Amana
a2155464e7
complete implementation and tests (#15977) 2022-01-06 15:49:35 -05:00
Michael Kohl
1c80304fd5
Remove htmlentities gem (#15958) 2022-01-06 21:14:32 +07:00