Skip to content

Commit

Permalink
Merge pull request #2456 from tvdeyen/fix-picture-show
Browse files Browse the repository at this point in the history
Fix picture show overlay if picture in use
  • Loading branch information
tvdeyen authored Apr 13, 2023
2 parents 3616f9f + b3dbcef commit d6ec268
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pictures/_infos.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<li class="<%= cycle('even', 'odd') %>">
<% page_link = link_to element.display_name_with_preview_text,
edit_admin_page_path(page, anchor: "element_#{element.id}") %>
<% ingredients = picture_ingredients.collect(&:translated_role).to_sentence %>
<% ingredients = picture_ingredients.map { |p| Alchemy::IngredientEditor.new(p).translated_role }.to_sentence %>
<% if element.public? %>
<%= render_icon('window-maximize', style: 'regular') %>
<% else %>
Expand Down
18 changes: 16 additions & 2 deletions spec/views/admin/pictures/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

before do
allow(view).to receive(:admin_picture_path).and_return("/path")
allow(view).to receive(:edit_admin_page_path).and_return("/path")
allow(view).to receive(:render_message)
allow(view).to receive(:search_filter_params) { {} }
view.extend Alchemy::Admin::FormHelper
view.extend Alchemy::BaseHelper
assign(:picture, picture)
end

it "displays picture in original format" do
assign(:picture, picture)
assign(:assignments, [])

render
Expand All @@ -36,11 +38,23 @@

it "separates the tags with a comma" do
allow(picture).to receive(:tag_list).and_return(["one", "two", "three"])
assign(:picture, picture)
assign(:assignments, [])

render

expect(rendered).to have_selector('input[value*="one,two,three"]')
end

context "if picture is used" do
let!(:picture_ingredient) { create(:alchemy_ingredient_picture, picture: picture) }

it "displays a list of ingredients using the picture" do
assign(:assignments, picture.picture_ingredients.joins(element: :page))

render

expect(rendered).to have_css("#pictures_page_list .list")
expect(rendered).to have_content Alchemy::IngredientEditor.new(picture_ingredient).translated_role
end
end
end

0 comments on commit d6ec268

Please sign in to comment.