* Initial basic work * Bulk of related work, including find/replace on the inputs * Adjust some tests * Adjust some specs * Fix a few more tests * Clean up tests * Adjust tests * Test fiddle * Adjust crop back to be a param * Update tests * Set proper defaults * Fix some styling * Adjust enrichment logic and tests * Adjust form JS * Update test snapshot * Clean up formatting * Fix spec name * Adjust some css and defaults * Adjust translation for image provider options * Switch from fill to fill-down * Proper fallback image * Fix tests * Update app/services/images/optimizer.rb Co-authored-by: Mac Siri <mac@forem.com> --------- Co-authored-by: Mac Siri <mac@forem.com>
46 lines
2.6 KiB
Ruby
46 lines
2.6 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe CloudCoverUrl, cloudinary: true, type: :view_object do
|
|
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
|
|
expect(described_class.new(article.main_image).call)
|
|
.to start_with(cloudinary_prefix)
|
|
.and include("/c_fill,f_auto,fl_progressive,h_420,q_auto,w_1000/https://robohash.org/")
|
|
end
|
|
|
|
it "returns proper url when nested cloudinary" do
|
|
image_url = "https://res.cloudinary.com/practicaldev/image/fetch/s--A-gun7rr--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://res.cloudinary.com/practicaldev/image/fetch/s--hcD8ZkbP--/c_imagga_scale%2Cf_auto%2Cfl_progressive%2Ch_420%2Cq_auto%2Cw_1000/https://dev-to-uploads.s3.amazonaws.com/i/th93d625o27nuz63oeen.png" # rubocop:disable Layout/LineLength
|
|
cloudinary_string = "/c_fill,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/th93d625o27nuz63oeen.png" # rubocop:disable Layout/LineLength
|
|
|
|
article.update_column(:main_image, image_url)
|
|
expect(described_class.new(article.main_image).call)
|
|
.to start_with(cloudinary_prefix)
|
|
.and end_with(cloudinary_string)
|
|
end
|
|
|
|
it "returns proper url when single cloudinary" do
|
|
image_url = "https://res.cloudinary.com/practicaldev/image/fetch/s--hcD8ZkbP--/c_imagga_scale%2Cf_auto%2Cfl_progressive%2Ch_420%2Cq_auto%2Cw_1000/https://dev-to-uploads.s3.amazonaws.com/i/th93d625o27nuz63oeen.png" # rubocop:disable Layout/LineLength
|
|
cloudinary_string = "/c_fill,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/th93d625o27nuz63oeen.png" # rubocop:disable Layout/LineLength
|
|
|
|
article.update_column(:main_image, image_url)
|
|
expect(described_class.new(article.main_image).call)
|
|
.to start_with(cloudinary_prefix)
|
|
.and end_with(cloudinary_string)
|
|
end
|
|
|
|
it "returns proper url when config set to limit" do
|
|
allow(Settings::UserExperience).to receive(:cover_image_fit).and_return("limit")
|
|
expect(described_class.new(article.main_image).call)
|
|
.to start_with(cloudinary_prefix)
|
|
.and include("/c_limit,f_auto,fl_progressive,h_420,q_auto,w_1000/https://robohash.org/")
|
|
end
|
|
|
|
it "returns proper url when height is set" do
|
|
allow(Settings::UserExperience).to receive(:cover_image_height).and_return("902")
|
|
expect(described_class.new(article.main_image).call)
|
|
.to start_with(cloudinary_prefix)
|
|
.and include("/c_fill,f_auto,fl_progressive,h_902,q_auto,w_1000/https://robohash.org/")
|
|
end
|
|
end
|