From de3e44459df68b3b7c09ccd29a710775ae686b31 Mon Sep 17 00:00:00 2001 From: Jack <113976590+bibblobcode@users.noreply.github.com> Date: Mon, 19 Jun 2023 16:07:32 +0100 Subject: [PATCH] Put bulk upload controller checks behind feature flag (#1712) --- .../bulk_upload_lettings_logs_controller.rb | 7 ++++--- app/controllers/bulk_upload_sales_logs_controller.rb | 7 ++++--- .../bulk_upload_lettings_logs_controller_spec.rb | 12 ++++++++++++ .../bulk_upload_sales_logs_controller_spec.rb | 12 ++++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/controllers/bulk_upload_lettings_logs_controller.rb b/app/controllers/bulk_upload_lettings_logs_controller.rb index 1d011dcca..035621e41 100644 --- a/app/controllers/bulk_upload_lettings_logs_controller.rb +++ b/app/controllers/bulk_upload_lettings_logs_controller.rb @@ -25,9 +25,10 @@ class BulkUploadLettingsLogsController < ApplicationController private def validate_data_protection_agrement_signed! - unless @current_user.organisation.data_protection_confirmed? - redirect_to lettings_logs_path - end + return unless FeatureToggle.new_data_protection_confirmation? + return if @current_user.organisation.data_protection_confirmed? + + redirect_to lettings_logs_path end def current_year diff --git a/app/controllers/bulk_upload_sales_logs_controller.rb b/app/controllers/bulk_upload_sales_logs_controller.rb index aa865f0c7..7a7a20297 100644 --- a/app/controllers/bulk_upload_sales_logs_controller.rb +++ b/app/controllers/bulk_upload_sales_logs_controller.rb @@ -25,9 +25,10 @@ class BulkUploadSalesLogsController < ApplicationController private def validate_data_protection_agrement_signed! - unless @current_user.organisation.data_protection_confirmed? - redirect_to sales_logs_path - end + return unless FeatureToggle.new_data_protection_confirmation? + return if @current_user.organisation.data_protection_confirmed? + + redirect_to sales_logs_path end def current_year diff --git a/spec/requests/bulk_upload_lettings_logs_controller_spec.rb b/spec/requests/bulk_upload_lettings_logs_controller_spec.rb index f901cdb7e..db5a3c4a6 100644 --- a/spec/requests/bulk_upload_lettings_logs_controller_spec.rb +++ b/spec/requests/bulk_upload_lettings_logs_controller_spec.rb @@ -18,6 +18,18 @@ RSpec.describe BulkUploadLettingsLogsController, type: :request do expect(response).to redirect_to("/lettings-logs") end + + context "when feature flag disabled" do + before do + allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false) + end + + it "does not redirect to lettings index page" do + get "/lettings-logs/bulk-upload-logs/start", params: {} + + expect(response).not_to redirect_to("/lettings-logs") + end + end end context "when not in crossover period" do diff --git a/spec/requests/bulk_upload_sales_logs_controller_spec.rb b/spec/requests/bulk_upload_sales_logs_controller_spec.rb index 3220ff885..c7de6598e 100644 --- a/spec/requests/bulk_upload_sales_logs_controller_spec.rb +++ b/spec/requests/bulk_upload_sales_logs_controller_spec.rb @@ -18,6 +18,18 @@ RSpec.describe BulkUploadSalesLogsController, type: :request do expect(response).to redirect_to("/sales-logs") end + + context "when feature flag disabled" do + before do + allow(FeatureToggle).to receive(:new_data_protection_confirmation?).and_return(false) + end + + it "does not redirect to lettings index page" do + get "/lettings-logs/bulk-upload-logs/start", params: {} + + expect(response).not_to redirect_to("/sales-logs") + end + end end context "when not in crossover period" do