Skip to content

Commit

Permalink
Show element editor if element has no contents but ingredients defined
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed Jun 28, 2021
1 parent 6cfdf75 commit c2363af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/decorators/alchemy/element_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def css_classes
def editable?
return false if folded?

content_definitions.present? || taggable?
content_definitions.present? || ingredient_definitions.any? || taggable?
end

# Fixes Rails partial renderer calling to_model on the object
Expand Down
12 changes: 12 additions & 0 deletions spec/decorators/alchemy/element_editor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@

it { is_expected.to eq(false) }
end

context "but element has ingredients defined" do
before {
expect(element).to receive(:ingredient_definitions) {
[{
role: "headline", type: "Headline",
}]
}
}

it { is_expected.to eq(true) }
end
end
end
end
Expand Down

0 comments on commit c2363af

Please sign in to comment.