Browse Source

CLDC-4231: add create test log buttons for 26/27 logs (#3180)

* CLDC-4231: add create test log buttons for current and next collection years

* CLDC-4231: remove end date overrides

* CLDC-4231: allow test logs on staging

* CLDC-4231: feature flag next year test logs by allow_future_form_use?
pull/3169/head^2
Nat Dean-Lewis 4 days ago committed by GitHub
parent
commit
c4f4298d01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 20
      app/components/create_log_actions_component.html.erb
  2. 17
      app/components/create_log_actions_component.rb
  3. 28
      app/controllers/test_data_controller.rb
  4. 2
      app/services/feature_toggle.rb
  5. 4
      config/routes.rb

20
app/components/create_log_actions_component.html.erb

@ -14,17 +14,33 @@
<span class="govuk-body govuk-body-s">These tools can only be seen and used in testing environments.</span>
<div>
<%= govuk_button_link_to create_test_log_href, class: "govuk-button" do %>
New test log
New <%= current_collection_year_label %> test log
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path>
</svg>
<% end %>
<% if FeatureToggle.allow_future_form_use? %>
<%= govuk_button_link_to create_next_year_test_log_href, class: "govuk-button" do %>
New <%= next_collection_year_label %> test log
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path>
</svg>
<% end %>
<% end %>
<%= govuk_button_link_to create_setup_test_log_href, class: "govuk-button" do %>
New test log (setup only)
New <%= current_collection_year_label %> test log (setup only)
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path>
</svg>
<% end %>
<% if FeatureToggle.allow_future_form_use? %>
<%= govuk_button_link_to create_next_year_setup_test_log_href, class: "govuk-button" do %>
New <%= next_collection_year_label %> test log (setup only)
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path>
</svg>
<% end %>
<% end %>
<%= govuk_button_link_to create_test_bulk_upload_href(2025), class: "govuk-button govuk-button--secondary" do %>
25/26 BU test file
<svg class="govuk-button__start-icon bi bi-download" xmlns="http://www.w3.org/2000/svg" width="18" height="19" fill="currentColor" viewBox="0 0 16 16" stroke="currentColor" stroke-width="1.4">

17
app/components/create_log_actions_component.rb

@ -1,5 +1,6 @@
class CreateLogActionsComponent < ViewComponent::Base
include Rails.application.routes.url_helpers
include CollectionTimeHelper
attr_reader :bulk_upload, :user, :log_type
@ -38,10 +39,26 @@ class CreateLogActionsComponent < ViewComponent::Base
send("create_test_#{log_type}_log_path")
end
def create_next_year_test_log_href
send("create_next_year_test_#{log_type}_log_path")
end
def create_setup_test_log_href
send("create_setup_test_#{log_type}_log_path")
end
def create_next_year_setup_test_log_href
send("create_next_year_setup_test_#{log_type}_log_path")
end
def current_collection_year_label
"#{current_collection_start_year - 2000}/#{current_collection_end_year - 2000}"
end
def next_collection_year_label
"#{next_collection_start_year - 2000}/#{next_collection_end_year - 2000}"
end
def create_test_bulk_upload_href(year)
send("create_#{year}_test_#{log_type}_bulk_upload_path")
end

28
app/controllers/test_data_controller.rb

@ -10,6 +10,13 @@ class TestDataController < ApplicationController
redirect_to lettings_log_path(log)
end
def create_next_year_test_lettings_log
return render_not_found unless FeatureToggle.create_test_logs_enabled?
log = FactoryBot.create(:lettings_log, :completed, assigned_to: current_user, ppostcode_full: "SW1A 1AA", manual_address_entry_selected: false, startdate: generate_different_date_within_collection_year(Time.zone.local(next_collection_start_year, 4, 1)))
redirect_to lettings_log_path(log)
end
def create_setup_test_lettings_log
return render_not_found unless FeatureToggle.create_test_logs_enabled?
@ -17,6 +24,13 @@ class TestDataController < ApplicationController
redirect_to lettings_log_path(log)
end
def create_next_year_setup_test_lettings_log
return render_not_found unless FeatureToggle.create_test_logs_enabled?
log = FactoryBot.create(:lettings_log, :setup_completed, assigned_to: current_user, manual_address_entry_selected: false, startdate: generate_different_date_within_collection_year(Time.zone.local(next_collection_start_year, 4, 1)))
redirect_to lettings_log_path(log)
end
%w[2025 2026].each do |year|
define_method("create_#{year}_test_lettings_bulk_upload") do
return render_not_found unless FeatureToggle.create_test_logs_enabled?
@ -47,6 +61,13 @@ class TestDataController < ApplicationController
redirect_to sales_log_path(log)
end
def create_next_year_test_sales_log
return render_not_found unless FeatureToggle.create_test_logs_enabled?
log = FactoryBot.create(:sales_log, :completed, assigned_to: current_user, manual_address_entry_selected: false, saledate: generate_different_date_within_collection_year(Time.zone.local(next_collection_start_year, 4, 1)))
redirect_to sales_log_path(log)
end
def create_setup_test_sales_log
return render_not_found unless FeatureToggle.create_test_logs_enabled?
@ -54,6 +75,13 @@ class TestDataController < ApplicationController
redirect_to sales_log_path(log)
end
def create_next_year_setup_test_sales_log
return render_not_found unless FeatureToggle.create_test_logs_enabled?
log = FactoryBot.create(:sales_log, :shared_ownership_setup_complete, assigned_to: current_user, manual_address_entry_selected: false, saledate: generate_different_date_within_collection_year(Time.zone.local(next_collection_start_year, 4, 1)))
redirect_to sales_log_path(log)
end
%w[2025 2026].each do |year|
define_method("create_#{year}_test_sales_bulk_upload") do
return render_not_found unless FeatureToggle.create_test_logs_enabled?

2
app/services/feature_toggle.rb

@ -28,7 +28,7 @@ class FeatureToggle
end
def self.create_test_logs_enabled?
Rails.env.development? || Rails.env.review?
Rails.env.development? || Rails.env.review? || Rails.env.staging?
end
def self.sales_export_enabled?

4
config/routes.rb

@ -405,11 +405,15 @@ Rails.application.routes.draw do
if FeatureToggle.create_test_logs_enabled?
get "create-test-lettings-log", to: "test_data#create_test_lettings_log"
get "create-next-year-test-lettings-log", to: "test_data#create_next_year_test_lettings_log"
get "create-setup-test-lettings-log", to: "test_data#create_setup_test_lettings_log"
get "create-next-year-setup-test-lettings-log", to: "test_data#create_next_year_setup_test_lettings_log"
get "create-2025-test-lettings-bulk-upload", to: "test_data#create_2025_test_lettings_bulk_upload"
get "create-2026-test-lettings-bulk-upload", to: "test_data#create_2026_test_lettings_bulk_upload"
get "create-test-sales-log", to: "test_data#create_test_sales_log"
get "create-next-year-test-sales-log", to: "test_data#create_next_year_test_sales_log"
get "create-setup-test-sales-log", to: "test_data#create_setup_test_sales_log"
get "create-next-year-setup-test-sales-log", to: "test_data#create_next_year_setup_test_sales_log"
get "create-2025-test-sales-bulk-upload", to: "test_data#create_2025_test_sales_bulk_upload"
get "create-2026-test-sales-bulk-upload", to: "test_data#create_2026_test_sales_bulk_upload"
end

Loading…
Cancel
Save