From 208cad959aad8f1c066f51704701d12ca4222c52 Mon Sep 17 00:00:00 2001 From: binarygit Date: Tue, 21 Nov 2023 13:33:48 +0545 Subject: [PATCH] Open external link in product description inside new page --- app/views/shop/products/_summary.html.haml | 2 +- spec/system/consumer/shopping/products_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/views/shop/products/_summary.html.haml b/app/views/shop/products/_summary.html.haml index 66479e2ff81..da625de3ee6 100644 --- a/app/views/shop/products/_summary.html.haml +++ b/app/views/shop/products/_summary.html.haml @@ -10,7 +10,7 @@ %h3 %a{"ng-click" => "triggerProductModal()", href: 'javascript:void(0)'} %span{"ng-bind" => "::product.name"} - .product-description{ng: {"bind-html": "::product.description_html", click: "triggerProductModal()", show: "product.description_html.length"}} + .product-description{ng: {"bind-html": "::product.description_html", click: "triggerProductModal()", show: "product.description_html.length"}, "data-controller": "add-blank-to-link"} %div{ "ng-switch" => "enterprise.visible" } .product-producer = t :products_from diff --git a/spec/system/consumer/shopping/products_spec.rb b/spec/system/consumer/shopping/products_spec.rb index c7cec7efa22..fdef556152e 100644 --- a/spec/system/consumer/shopping/products_spec.rb +++ b/spec/system/consumer/shopping/products_spec.rb @@ -113,6 +113,14 @@ expect(page).to have_content "alert('Dangerous!'); Safe" end end + + it "opens link in product description inside another window" do + product.description = "external site" + product.save! + + visit shop_path + expect(find_link('external site')[:target]).to eq('_blank') + end end describe "filtering" do