From 478dd6807293fc361ab5833cc96c2a64485e6ed8 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 11 Sep 2018 17:25:11 +0100 Subject: [PATCH] In cookies policy helper, added string interpolation to variable to avoid variable (Spree::Config entry) to break the concatenation. Added unit test to validate the error case --- app/helpers/cookies_policy_helper.rb | 2 +- spec/helpers/cookies_policy_helper_spec.rb | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/helpers/cookies_policy_helper.rb b/app/helpers/cookies_policy_helper.rb index 98db25d698..5bcec92383 100644 --- a/app/helpers/cookies_policy_helper.rb +++ b/app/helpers/cookies_policy_helper.rb @@ -7,7 +7,7 @@ module CookiesPolicyHelper end def matomo_iframe_src - Spree::Config.matomo_url\ + "#{Spree::Config.matomo_url}"\ "/index.php?module=CoreAdminHome&action=optOut"\ "&language=#{locale_language}"\ "&backgroundColor=&fontColor=222222&fontSize=16px&fontFamily=%22Roboto%22%2C%20Arial%2C%20sans-serif" diff --git a/spec/helpers/cookies_policy_helper_spec.rb b/spec/helpers/cookies_policy_helper_spec.rb index 2e4fbfa25d..b09f578a32 100644 --- a/spec/helpers/cookies_policy_helper_spec.rb +++ b/spec/helpers/cookies_policy_helper_spec.rb @@ -12,9 +12,18 @@ describe CookiesPolicyHelper, type: :helper do end describe "matomo optout iframe src" do - scenario "includes matomo URL" do - Spree::Config.matomo_url = "http://matomo.org/" - expect(helper.matomo_iframe_src).to include Spree::Config.matomo_url + describe "when matomo url is set" do + before do + Spree::Config.matomo_url = "http://matomo.org/" + end + + scenario "includes the matomo URL" do + expect(helper.matomo_iframe_src).to include Spree::Config.matomo_url + end + + scenario "is not equal to the matomo URL" do + expect(helper.matomo_iframe_src).to_not eq Spree::Config.matomo_url + end end scenario "is not nil, when matomo url is nil" do