From 1a185ade03f5b40ecb8b3fe04402eef9e5c3f035 Mon Sep 17 00:00:00 2001 From: Adrien Chauve Date: Sun, 17 Oct 2021 23:52:03 +0200 Subject: [PATCH 1/2] Add links to external site in product view test --- .../consumer/shopping/products_spec.rb | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/spec/features/consumer/shopping/products_spec.rb b/spec/features/consumer/shopping/products_spec.rb index c4f101de0f..b23bef7c27 100644 --- a/spec/features/consumer/shopping/products_spec.rb +++ b/spec/features/consumer/shopping/products_spec.rb @@ -31,7 +31,7 @@ describe "As a consumer I want to view products", js: true do end it "shows HTML product description" do - product.description = "

Formatted product description.

" + product.description = '

Formatted product description.

Link to an external site' product.save! visit shop_path @@ -42,7 +42,26 @@ describe "As a consumer I want to view products", js: true do modal_should_be_open_for product within(".reveal-modal") do - expect(html).to include("

Formatted product description.

") + expect(html).to include('

Formatted product description.

Link to an external site') + end + + # -- edit product via admin interface + login_as_admin_and_visit spree.edit_admin_product_path(product) + expect(page.find("div[id^='taTextElement']")['innerHTML']).to include('external site') + + fill_in 'product_name', with: product.name + "_update" + click_button 'Update' + + # -- check back consumer product view + visit shop_path + expect(page).to have_content(product.name + "_update") + click_link(product.name + "_update") + + expect(page).to have_selector '.reveal-modal' + modal_should_be_open_for product + + within(".reveal-modal") do + expect(html).to include('

Formatted product description.

Link to an external site') end end From bd3bea8025c91aa78090e0281796152da87c9582 Mon Sep 17 00:00:00 2001 From: Adrien Chauve Date: Wed, 13 Oct 2021 16:52:23 +0200 Subject: [PATCH 2/2] Fix: product edition doesn't break description links -> otherwise product edition was breaking description links, which were not opening in a new tab anymore. --- app/views/spree/admin/products/_form.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/spree/admin/products/_form.html.haml b/app/views/spree/admin/products/_form.html.haml index ff97183eca..f9f90443f1 100644 --- a/app/views/spree/admin/products/_form.html.haml +++ b/app/views/spree/admin/products/_form.html.haml @@ -12,8 +12,8 @@ = f.field_container :description do = f.label :description, t(:description) - %text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', "textangular-links-target-blank" => true, 'ta-toolbar' => "[['bold','italics','underline','clear'],['insertLink']]"} - = sanitize(@product.description) + %text-angular{'id' => 'product_description', 'name' => 'product[description]', 'class' => 'text-angular', 'textangular-unsafe-sanitizer' => true, "textangular-links-target-blank" => true, 'ta-toolbar' => "[['bold','italics','underline','clear'],['insertLink']]"} + = sanitize(@product.description, attributes: ["href", "target"]) = f.error_message_on :description .right.four.columns.omega