Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix picture show overlay if picture in use #2456

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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