From ccd5147b113ee5fe6d893f9f99028f3aec490e1a Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 13 Aug 2018 17:25:51 +0100 Subject: [PATCH] Added angular templates route and controller to serve angular templates from the server, instead of precompiled assets. This was used to fix a problem with the cookies policy page template that was using a Spree configuration --- .../cookies_policy/cookies_policy_modal_service.js.coffee | 2 +- app/controllers/angular_templates_controller.rb | 5 +++++ .../angular_templates}/cookies_policy.html.haml | 0 config/routes.rb | 2 ++ spec/features/consumer/cookies_spec.rb | 5 ++--- 5 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 app/controllers/angular_templates_controller.rb rename app/{assets/javascripts/darkswarm/cookies_policy => views/angular_templates}/cookies_policy.html.haml (100%) diff --git a/app/assets/javascripts/darkswarm/cookies_policy/cookies_policy_modal_service.js.coffee b/app/assets/javascripts/darkswarm/cookies_policy/cookies_policy_modal_service.js.coffee index 5377018089..0f91645cfd 100644 --- a/app/assets/javascripts/darkswarm/cookies_policy/cookies_policy_modal_service.js.coffee +++ b/app/assets/javascripts/darkswarm/cookies_policy/cookies_policy_modal_service.js.coffee @@ -8,7 +8,7 @@ Darkswarm.factory "CookiesPolicyModalService", (Navigation, $modal, $location, C if $location.path() is @defaultPath || location.pathname is @defaultPath @open '' - open: (path = false, template = 'darkswarm/cookies_policy/cookies_policy.html') => + open: (path = false, template = 'angular-templates/cookies_policy.html') => @modalInstance = $modal.open templateUrl: template windowClass: "cookies-policy-modal medium" diff --git a/app/controllers/angular_templates_controller.rb b/app/controllers/angular_templates_controller.rb new file mode 100644 index 0000000000..44d870cc58 --- /dev/null +++ b/app/controllers/angular_templates_controller.rb @@ -0,0 +1,5 @@ +class AngularTemplatesController < ApplicationController + def show + render params[:id].to_s, layout: nil + end +end diff --git a/app/assets/javascripts/darkswarm/cookies_policy/cookies_policy.html.haml b/app/views/angular_templates/cookies_policy.html.haml similarity index 100% rename from app/assets/javascripts/darkswarm/cookies_policy/cookies_policy.html.haml rename to app/views/angular_templates/cookies_policy.html.haml diff --git a/config/routes.rb b/config/routes.rb index ed4f517a4a..a1ce680804 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -80,6 +80,8 @@ Openfoodnetwork::Application.routes.draw do get '/:id/shop', to: 'enterprises#shop', as: 'enterprise_shop' get "/enterprises/:permalink", to: redirect("/") # Legacy enterprise URL + get "/angular-templates/:id", to: "angular_templates#show", constraints: { name: %r{[\/\w\.]+} } + namespace :api do resources :enterprises do post :update_image, on: :member diff --git a/spec/features/consumer/cookies_spec.rb b/spec/features/consumer/cookies_spec.rb index 84f4f0d3b7..b9755ddc5a 100644 --- a/spec/features/consumer/cookies_spec.rb +++ b/spec/features/consumer/cookies_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature "Cookies", js: true do - describe "banner", js: true do + describe "banner" do describe "in the homepage" do before do Spree::Config[:cookies_consent_banner_toggle] = true @@ -57,8 +57,7 @@ feature "Cookies", js: true do scenario "shows Matomo cookies details" do Spree::Config[:cookies_policy_matomo_section] = true visit '/#/policies/cookies' - # before { skip("test not working, settings are not picked up") } - # expect(page).to have_content matomo_description_text + expect(page).to have_content matomo_description_text end end