Skip to content

Commit

Permalink
Add has_tinymce? to ingredient
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed May 27, 2021
1 parent e3c6af0 commit 87b4377
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/alchemy/ingredient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ def deprecated?
!!definition[:deprecated]
end

# @return [Boolean]
def has_tinymce?
false
end

private

def hint_translation_attribute
Expand Down
4 changes: 4 additions & 0 deletions app/models/alchemy/ingredients/richtext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def tinymce_class_name
"has_tinymce" + (has_custom_tinymce_config? ? " #{element.name}_#{role}" : "")
end

def has_tinymce?
true
end

private

def strip_content
Expand Down
8 changes: 8 additions & 0 deletions spec/models/alchemy/ingredient_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,12 @@
it { is_expected.to be true }
end
end

describe "#has_tinymce?" do
subject { ingredient.has_tinymce? }

let(:ingredient) { Alchemy::Ingredient.build(role: "headline", element: element) }

it { is_expected.to be(false) }
end
end
6 changes: 6 additions & 0 deletions spec/models/alchemy/ingredients/richtext_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
end
end

describe "#has_tinymce?" do
subject { richtext_ingredient.has_tinymce? }

it { is_expected.to be(true) }
end

describe "preview_text" do
subject { richtext_ingredient.tap(&:save).preview_text }

Expand Down

0 comments on commit 87b4377

Please sign in to comment.