-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2163 from tvdeyen/fix-tinymce-init-for-ingredients
(Re)-init Tinymce for elements with ingredients
- Loading branch information
Showing
5 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe Alchemy::Admin::ElementsController do | ||
before do | ||
authorize_user(:as_admin) | ||
end | ||
|
||
describe "#create" do | ||
let(:page_version) { create(:alchemy_page_version) } | ||
|
||
context "element with ingredients" do | ||
it "inits Tinymce for richtext ingredients" do | ||
post admin_elements_path(element: { page_version_id: page_version.id, name: "element_with_ingredients" }, format: :js) | ||
element = Alchemy::Element.last | ||
expect(response.body).to include("Alchemy.Tinymce.init([#{element.ingredient_by_role(:text).id}]);") | ||
end | ||
end | ||
end | ||
|
||
describe "#fold" do | ||
context "expanded element with ingredients" do | ||
let(:element) { create(:alchemy_element, :with_ingredients) } | ||
|
||
it "removes Tinymce for richtext ingredients" do | ||
post fold_admin_element_path(id: element.id, format: :js) | ||
expect(response.body).to include("Alchemy.Tinymce.remove([#{element.ingredient_by_role(:text).id}]);") | ||
end | ||
end | ||
|
||
context "folded element with ingredients" do | ||
let(:element) { create(:alchemy_element, :with_ingredients, folded: true) } | ||
|
||
it "inits Tinymce for richtext ingredients" do | ||
post fold_admin_element_path(id: element.id, format: :js) | ||
expect(response.body).to include("Alchemy.Tinymce.init([#{element.ingredient_by_role(:text).id}]);") | ||
end | ||
end | ||
end | ||
|
||
describe "#destroy" do | ||
context "element with ingredients" do | ||
let(:element) { create(:alchemy_element, :with_ingredients) } | ||
|
||
it "removes Tinymce for richtext ingredients" do | ||
delete admin_element_path(id: element.id, format: :js) | ||
expect(response.body).to include("Alchemy.Tinymce.remove([#{element.ingredient_by_role(:text).id}]);") | ||
end | ||
end | ||
end | ||
end |