16 changed files with 296 additions and 2 deletions
@ -0,0 +1,27 @@ |
|||||||
|
module Forms |
||||||
|
module BulkUploadLettings |
||||||
|
class PrepareYourFile |
||||||
|
include ActiveModel::Model |
||||||
|
|
||||||
|
attr_accessor :year |
||||||
|
|
||||||
|
def view_path |
||||||
|
"bulk_upload_lettings_logs/forms/prepare_your_file" |
||||||
|
end |
||||||
|
|
||||||
|
def back_path |
||||||
|
if in_crossover_period? |
||||||
|
Rails.application.routes.url_helpers.bulk_upload_lettings_log_path(id: "year", form: { year: }) |
||||||
|
else |
||||||
|
Rails.application.routes.url_helpers.lettings_logs_path |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
private |
||||||
|
|
||||||
|
def in_crossover_period? |
||||||
|
FormHandler.instance.forms.values.any?(&:in_crossover_period?) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
module Forms |
||||||
|
module BulkUploadLettings |
||||||
|
class Year |
||||||
|
include ActiveModel::Model |
||||||
|
|
||||||
|
attr_accessor :year |
||||||
|
|
||||||
|
validates :year, presence: true |
||||||
|
|
||||||
|
def view_path |
||||||
|
"bulk_upload_lettings_logs/forms/year" |
||||||
|
end |
||||||
|
|
||||||
|
def options |
||||||
|
[ |
||||||
|
OpenStruct.new(id: "2022", name: "2022/2023"), |
||||||
|
OpenStruct.new(id: "2021", name: "2021/2022"), |
||||||
|
] |
||||||
|
end |
||||||
|
|
||||||
|
def back_path |
||||||
|
Rails.application.routes.url_helpers.lettings_logs_path |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
module Forms |
||||||
|
module BulkUploadSales |
||||||
|
class PrepareYourFile |
||||||
|
include ActiveModel::Model |
||||||
|
|
||||||
|
attr_accessor :year |
||||||
|
|
||||||
|
def view_path |
||||||
|
"bulk_upload_sales_logs/forms/prepare_your_file" |
||||||
|
end |
||||||
|
|
||||||
|
def back_path |
||||||
|
if in_crossover_period? |
||||||
|
Rails.application.routes.url_helpers.bulk_upload_sales_log_path(id: "year", form: { year: }) |
||||||
|
else |
||||||
|
Rails.application.routes.url_helpers.sales_logs_path |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def in_crossover_period? |
||||||
|
FormHandler.instance.forms.values.any?(&:in_crossover_period?) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
module Forms |
||||||
|
module BulkUploadSales |
||||||
|
class Year |
||||||
|
include ActiveModel::Model |
||||||
|
|
||||||
|
attr_accessor :year |
||||||
|
|
||||||
|
validates :year, presence: true |
||||||
|
|
||||||
|
def view_path |
||||||
|
"bulk_upload_sales_logs/forms/year" |
||||||
|
end |
||||||
|
|
||||||
|
def options |
||||||
|
[ |
||||||
|
OpenStruct.new(id: "2022", name: "2022/2023"), |
||||||
|
OpenStruct.new(id: "2021", name: "2021/2022"), |
||||||
|
] |
||||||
|
end |
||||||
|
|
||||||
|
def back_path |
||||||
|
Rails.application.routes.url_helpers.sales_logs_path |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,15 @@ |
|||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link href: @form.back_path %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= form_with model: @form, scope: :form, url: bulk_upload_lettings_log_path(id: "prepare-your-file"), method: :patch do |f| %> |
||||||
|
<div> |
||||||
|
prepare file goes here |
||||||
|
</div> |
||||||
|
|
||||||
|
<div> |
||||||
|
year selected <%= @form.year %> |
||||||
|
</div> |
||||||
|
|
||||||
|
<%= f.govuk_submit %> |
||||||
|
<% end %> |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link href: @form.back_path %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= form_with model: @form, scope: :form, url: bulk_upload_lettings_log_path(id: "year"), method: :patch do |f| %> |
||||||
|
<%= f.govuk_error_summary %> |
||||||
|
|
||||||
|
<%= f.govuk_collection_radio_buttons :year, |
||||||
|
@form.options, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: { text: "Which year are you uploading data for?", size: "l" }, |
||||||
|
caption: { text: "Upload lettings logs in bulk", size: "l" } %> |
||||||
|
|
||||||
|
<%= f.govuk_submit %> |
||||||
|
<% end %> |
||||||
@ -1 +0,0 @@ |
|||||||
Find me in app/views/bulk_upload_lettings_logs/show.html.erb |
|
||||||
@ -0,0 +1,15 @@ |
|||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link href: @form.back_path %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= form_with model: @form, scope: :form, url: bulk_upload_sales_log_path(id: "prepare-your-file"), method: :patch do |f| %> |
||||||
|
<div> |
||||||
|
prepare file goes here |
||||||
|
</div> |
||||||
|
|
||||||
|
<div> |
||||||
|
year selected <%= @form.year %> |
||||||
|
</div> |
||||||
|
|
||||||
|
<%= f.govuk_submit %> |
||||||
|
<% end %> |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
<% content_for :before_content do %> |
||||||
|
<%= govuk_back_link href: @form.back_path %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<%= form_with model: @form, scope: :form, url: bulk_upload_sales_log_path(id: "year"), method: :patch do |f| %> |
||||||
|
<%= f.govuk_error_summary %> |
||||||
|
|
||||||
|
<%= f.govuk_collection_radio_buttons :year, |
||||||
|
@form.options, |
||||||
|
:id, |
||||||
|
:name, |
||||||
|
legend: { text: "Which year are you uploading data for?", size: "l" }, |
||||||
|
caption: { text: "Upload sales logs in bulk", size: "l" } %> |
||||||
|
|
||||||
|
<%= f.govuk_submit %> |
||||||
|
<% end %> |
||||||
@ -1 +0,0 @@ |
|||||||
Find me in app/views/bulk_upload_sales_logs/show.html.erb |
|
||||||
@ -0,0 +1,32 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe "Bulk upload lettings log" do |
||||||
|
let(:user) { create(:user) } |
||||||
|
|
||||||
|
before do |
||||||
|
sign_in user |
||||||
|
end |
||||||
|
|
||||||
|
context "when during crossover period" do |
||||||
|
it "shows journey with year option" do |
||||||
|
Timecop.freeze(2023, 6, 1) do |
||||||
|
visit("/lettings-logs") |
||||||
|
expect(page).to have_link("Upload lettings log in bulk") |
||||||
|
click_link("Upload lettings log in bulk") |
||||||
|
|
||||||
|
expect(page).to have_content("Which year") |
||||||
|
click_button("Continue") |
||||||
|
|
||||||
|
expect(page).to have_content("You must select a collection period to upload for") |
||||||
|
choose("2022/2023") |
||||||
|
|
||||||
|
click_button("Continue") |
||||||
|
|
||||||
|
expect(page).to have_content("prepare file goes here") |
||||||
|
click_link("Back") |
||||||
|
|
||||||
|
expect(page.find_field("form-year-2022-field")).to be_checked |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
require "rails_helper" |
||||||
|
|
||||||
|
RSpec.describe "Bulk upload sales log" do |
||||||
|
let(:user) { create(:user) } |
||||||
|
|
||||||
|
before do |
||||||
|
sign_in user |
||||||
|
end |
||||||
|
|
||||||
|
context "when during crossover period" do |
||||||
|
it "shows journey with year option" do |
||||||
|
Timecop.freeze(2023, 6, 1) do |
||||||
|
visit("/sales-logs") |
||||||
|
expect(page).to have_link("Upload sales log in bulk") |
||||||
|
click_link("Upload sales log in bulk") |
||||||
|
|
||||||
|
expect(page).to have_content("Which year") |
||||||
|
click_button("Continue") |
||||||
|
|
||||||
|
expect(page).to have_content("You must select a collection period to upload for") |
||||||
|
choose("2022/2023") |
||||||
|
click_button("Continue") |
||||||
|
|
||||||
|
expect(page).to have_content("prepare file goes here") |
||||||
|
click_link("Back") |
||||||
|
|
||||||
|
expect(page.find_field("form-year-2022-field")).to be_checked |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
Loading…
Reference in new issue