diff --git a/lib/middlewares/redirect_middleware.rb b/lib/middlewares/redirect_middleware.rb index 6c023e7a..ff295259 100644 --- a/lib/middlewares/redirect_middleware.rb +++ b/lib/middlewares/redirect_middleware.rb @@ -12,6 +12,8 @@ def call(env) [301, { "Location" => request.url.sub("/futur-europa", "/processes/FuturEuropa") }, []] elsif request.path.starts_with?("/participacooperacio") [301, { "Location" => request.url.sub("/participacooperacio", "/processes/pladirectorcooperacio") }, []] + elsif request.path.starts_with?("/assembleaclima") + [301, { "Location" => request.url.sub("/assembleaclima", "/processes/assembleaclima") }, []] else @app.call(env) end diff --git a/spec/system/future_europe_spec.rb b/spec/system/future_europe_spec.rb deleted file mode 100644 index 865b7c72..00000000 --- a/spec/system/future_europe_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require "rails_helper" - -describe "Futur Europa redirect", type: :system do - let(:title_ca) { "El futur d'Europa" } - let!(:process) { create(:participatory_process, slug: "FuturEuropa", title: { ca: title_ca }) } - let!(:organization) { process.organization } - - before do - switch_to_host(organization.host) - end - - it "redirects to the process when /futur-europa is visited" do - visit "/futur-europa" - expect(page).to have_content(title_ca) - end -end diff --git a/spec/system/redirect_middleware_spec.rb b/spec/system/redirect_middleware_spec.rb new file mode 100644 index 00000000..d95b281a --- /dev/null +++ b/spec/system/redirect_middleware_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require "rails_helper" + +describe "Redirect Middleware", type: :system do + let!(:organization) { process.organization } + let!(:process) { create(:participatory_process, slug: slug, title: { ca: title_ca }) } + + before do + switch_to_host(organization.host) + end + + describe "Futur Europa redirect" do + let(:title_ca) { "El futur d'Europa" } + let(:slug) { "FuturEuropa" } + + it "redirects to the process when /futur-europa is visited" do + visit "/futur-europa" + expect(page).to have_content(title_ca) + end + end + + describe "Pla director cooperaciĆ³" do + let(:title_ca) { "Pla director cooperaciĆ³" } + let(:slug) { "pladirectorcooperacio" } + + it "redirects to the process when /participacooperacio is visited" do + visit "/participacooperacio" + expect(page).to have_content(title_ca) + end + end + + describe "Assemblea clima" do + let(:title_ca) { "Assemblea clima" } + let(:slug) { "assembleaclima" } + + it "redirects to the process when /assembleaclima is visited" do + visit "/assembleaclima" + expect(page).to have_content(title_ca) + end + end +end