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

This commit is contained in:
luisramos0
2018-09-11 17:25:11 +01:00
parent 409f084bd4
commit 478dd68072
2 changed files with 13 additions and 4 deletions

View File

@@ -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"

View File

@@ -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