Fix image width for feed location (#19321)
* Fix image width for feed location * Fix typo
This commit is contained in:
parent
6e7957f1c0
commit
3b22dada38
2 changed files with 19 additions and 1 deletions
|
|
@ -142,6 +142,6 @@ class DisplayAd < ApplicationRecord
|
|||
end
|
||||
|
||||
def prefix_width
|
||||
placement_area.to_s == "post_comments" ? POST_WIDTH : SIDEBAR_WIDTH
|
||||
placement_area.include?("sidebar") ? SIDEBAR_WIDTH : POST_WIDTH
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -117,6 +117,24 @@ RSpec.describe DisplayAd do
|
|||
# Images::Optimizer.call(source, width: width)
|
||||
end
|
||||
|
||||
it "uses sidebar width for sidebar location" do
|
||||
image_url = "https://dummyimage.com/100x100"
|
||||
allow(FastImage).to receive(:size)
|
||||
allow(Images::Optimizer).to receive(:call).and_return(image_url)
|
||||
image_md = "<p style='margin-top:100px'>Hello <em>hey</em> Hey hey</p>"
|
||||
create(:display_ad, body_markdown: image_md, placement_area: "post_sidebar")
|
||||
expect(Images::Optimizer).to have_received(:call).with(image_url, width: DisplayAd::SIDEBAR_WIDTH)
|
||||
end
|
||||
|
||||
it "uses post width for feed location" do
|
||||
image_url = "https://dummyimage.com/100x100"
|
||||
allow(FastImage).to receive(:size)
|
||||
allow(Images::Optimizer).to receive(:call).and_return(image_url)
|
||||
image_md = "<p style='margin-top:100px'>Hello <em>hey</em> Hey hey</p>"
|
||||
create(:display_ad, body_markdown: image_md, placement_area: "feed_second")
|
||||
expect(Images::Optimizer).to have_received(:call).with(image_url, width: DisplayAd::POST_WIDTH)
|
||||
end
|
||||
|
||||
it "keeps the same processed_html if markdown was not changed" do
|
||||
display_ad = create(:display_ad)
|
||||
html = display_ad.processed_html
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue