docbrown/spec/views/dashboards/show.html.erb_spec.rb
Jamie Gaskins 70cf28ca7b
Fix rotation of images uploaded from iPhones (#15010)
* Fix rotation of images uploaded from iPhones

iPhones[1] take pictures in portrait mode with the orientation set to
90ºCCW. We noticed that uploading one of these images to a Forem
instance caused the image to be rotated when rendered. The current
theory is that Imgproxy is not maintaining the orientation value when
processing, which is solved by setting `auto_rotate: true` (serialized
into the Imgproxy URL as `ar:1`), according to the documentation.

See: 8e6585e28d/docs/generating_the_url_advanced.md (auto-rotate)

[1] This probably happens with other phones, but we discovered the issue
using an iPhone.

* Fix Imgproxy URL expectation for auto_rotate
2021-10-11 15:17:14 -04:00

21 lines
778 B
Ruby

require "rails_helper"
RSpec.describe "dashboards/show.html.erb", type: :view do
before do
stub_template "dashboards/_actions_mobile.html.erb" => "stubbed content"
stub_template "dashboards/_analytics.html.erb" => "stubbed content"
stub_template "dashboards/_actions.html.erb" => "stubbed content"
allow(Images::Optimizer).to receive(:imgproxy_enabled?).and_return(true)
allow(Settings::General).to receive(:mascot_image_url).and_return("https://i.imgur.com/fKYKgo4.png")
end
context "when using Imgproxy" do
it "renders mascot image properly" do
assign(:user, create(:user))
assign(:articles, [])
render
expect(rendered).to match(%r{/w:300/mb:500000/ar:1/aHR0cHM6Ly9pLmlt/Z3VyLmNvbS9mS1lL/Z280LnBuZw})
end
end
end