From db72617b619dc13ef03ea16c1e95ccdfb9f9698e Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Tue, 18 May 2021 16:10:43 +0530 Subject: [PATCH 1/2] FIX: changed wizard id resolution logic --- extensions/extra_locales_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/extra_locales_controller.rb b/extensions/extra_locales_controller.rb index e7c5a02e..6242f7ca 100644 --- a/extensions/extra_locales_controller.rb +++ b/extensions/extra_locales_controller.rb @@ -4,7 +4,8 @@ module ExtraLocalesControllerCustomWizard super || begin return false unless bundle =~ /wizard/ && request.referer =~ /\/w\// path = URI(request.referer).path - wizard_id = path.split('/w/').last + wizard_path = path.split('/w/').last + wizard_id = wizard_path.split('/').first CustomWizard::Template.exists?(wizard_id.underscore) end end From 61ff01824400188ddf281f2bf0faaf31330c4046 Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Sun, 30 May 2021 18:30:51 +0530 Subject: [PATCH 2/2] added spec --- spec/extensions/extra_locales_controller_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/extensions/extra_locales_controller_spec.rb b/spec/extensions/extra_locales_controller_spec.rb index 91a4e8c3..a71e39c4 100644 --- a/spec/extensions/extra_locales_controller_spec.rb +++ b/spec/extensions/extra_locales_controller_spec.rb @@ -37,6 +37,13 @@ describe ExtraLocalesControllerCustomWizard, type: :request do expect(response.status).to eq(200) end + it "returns wizard locales when requested by user in a wizard step" do + sign_in(new_user) + + get @locale_url, headers: { 'REFERER' => "/w/super-mega-fun-wizard/steps/step_1" } + expect(response.status).to eq(200) + end + it "return wizard locales if user cant access wizard" do template[:permitted] = permitted["permitted"] CustomWizard::Template.save(template.as_json)