Commit graph

6 commits

Author SHA1 Message Date
Daniel Uber
39c339247b
Avoid using robohash for factory generated article cover images (#17024)
* Avoid using robohash for article cover images

If their service slows down, loading the cover image times out in
system tests.

Use a locally served image file instead.

* Specify expected image format for view object test

We were relying on the internals of Faker to return a robohash.org url
and checking that we included that in the cloudinary url.

Rather than relying on the default behavior, explicitly pass a
robohash url in the main image for this spec.
2022-03-28 14:01:29 -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
rhymes
a798bd2f7d
[15 min fix] Fallback to the image URL if Cloudinary/Imgproxy are not configured (#13767)
* Fallback to the image URL if neither Cloudinary nor Imgproxy are configured

* Fix specs

* Cloudinary api_secret is required

* Update spec/models/message_spec.rb

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

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-05-19 15:03:20 +02:00
rhymes
cc8bfcb5c0
Enable Rubocop 0.89 cops and fix Lint/ violations (#9709)
* Enable new Lint/ cops and run rubocop -a

* Fixing last remaining things with rubocop -a

* Enable and fix Style/ExplicitBlockArgument and Style/GlobalStdStream

* Forgot parenthesis
2020-08-10 16:57:12 +02:00
Mac Siri
3c5b01d490
[deploy] Implement ImageResizer module (#9652)
* Create ImageResizer module

* Refactor HtmlVariant

* Refactor CloudCoverUrl

* Fix broken spec

* Refactor PodcastEpisode

* Refactor Message

* Fix broken spec

* Refactor Articles::SocialImage

* Refactor ProfileImage & add spec

* Fix broken spec
2020-08-07 11:04:31 -04:00
Ben Halpern
eb768a24ad
[deploy] Add explicit robots instruction meta tag and adjust cloudinary (#9601)
* Add explicit robots instruction meta tag and adjust cloudinary

* Fix tests

* Fix test to account for random input

* Skip test
2020-08-02 11:25:46 -04:00