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.
This commit is contained in:
Daniel Uber 2022-03-28 14:01:29 -05:00 committed by GitHub
parent 6c319b8eb7
commit 39c339247b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -23,7 +23,11 @@ FactoryBot.define do
co_author_ids { [] }
association :user, factory: :user, strategy: :create
description { Faker::Hipster.paragraph(sentence_count: 1)[0..100] }
main_image { with_main_image ? Faker::Avatar.image : nil }
main_image do
if with_main_image
URL.url(ActionController::Base.helpers.asset_path("#{rand(1..40)}.png"))
end
end
experience_level_rating { rand(4..6) }
body_markdown do
<<~HEREDOC

View file

@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe CloudCoverUrl, type: :view_object, cloudinary: true do
let(:article) { create(:article) }
let(:article) { create(:article, main_image: "https://robohash.org/articlefactory.png") }
let(:cloudinary_prefix) { "https://res.cloudinary.com/#{Cloudinary.config.cloud_name}/image/fetch/" }
it "returns proper url" do