docbrown/spec/views/dashboards/show.html.erb_spec.rb
Ben Halpern ec7adf56fe
Allow admins to set cover image height configs (#19936)
* 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>
2023-08-21 13:25:16 -04:00

27 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe "dashboards/show" 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")
# These three lines are required for assisting the view in handling a policy.
# This issue highlights a continued problem: https://github.com/varvet/pundit/issues/163
view.extend(Pundit::Authorization)
policy = instance_double(ArticlePolicy, create?: true)
allow(view).to receive(:policy).and_return(policy)
end
context "when using Imgproxy" do
it "renders mascot image properly" do
assign(:user, create(:user))
assign(:articles, [])
render
expect(rendered).to match(%r{/rt:fill/w:300/g:sm/mb:500000/ar:1/aHR0cHM6Ly9pLmlt/Z3VyLmNvbS9mS1lL/Z280LnBuZw})
end
end
end