diff --git a/app/components/alchemy/ingredients/picture_view.rb b/app/components/alchemy/ingredients/picture_view.rb index 2caa647fbe..d32ab0ab99 100644 --- a/app/components/alchemy/ingredients/picture_view.rb +++ b/app/components/alchemy/ingredients/picture_view.rb @@ -65,7 +65,7 @@ def call def caption return unless show_caption? - @_caption ||= content_tag(:figcaption, ingredient.caption) + @_caption ||= content_tag(:figcaption, ingredient.caption.html_safe) end def src diff --git a/app/models/alchemy/picture_variant.rb b/app/models/alchemy/picture_variant.rb index 64035ada22..8e2f291d75 100644 --- a/app/models/alchemy/picture_variant.rb +++ b/app/models/alchemy/picture_variant.rb @@ -43,7 +43,7 @@ def initialize(picture, options = {}) @picture = picture @options = options - @render_format = options[:format] || picture.default_render_format + @render_format = (options[:format] || picture.default_render_format).to_s end # Process a variant of picture diff --git a/spec/components/alchemy/ingredients/picture_view_spec.rb b/spec/components/alchemy/ingredients/picture_view_spec.rb index b8ebabf9e2..22d3c901a8 100644 --- a/spec/components/alchemy/ingredients/picture_view_spec.rb +++ b/spec/components/alchemy/ingredients/picture_view_spec.rb @@ -52,6 +52,22 @@ expect(page).to have_content("This is a cute cat") end + context "having html tags" do + let(:ingredient) do + stub_model Alchemy::Ingredients::Picture, + role: "image", + picture: picture, + data: { + caption: "This is a
cute cat" + } + end + + it "should show the caption" do + render_view + expect(page).to have_content("This is acute cat") + end + end + it "does not pass default options to picture url" do expect(ingredient).to receive(:picture_url).with({}) { picture_url } render_view diff --git a/spec/models/alchemy/picture_variant_spec.rb b/spec/models/alchemy/picture_variant_spec.rb index 7711f435f5..679c6164c5 100644 --- a/spec/models/alchemy/picture_variant_spec.rb +++ b/spec/models/alchemy/picture_variant_spec.rb @@ -231,6 +231,18 @@ end end end + + context "passed as symbol" do + let(:options) do + {format: :gif} + end + + it "converts the format" do + step = subject.steps[0] + expect(step.name).to eq(:encode) + expect(step.arguments).to include("gif") + end + end end context "requesting a not allowed format" do