Browse Source

various minor changes following tech review

pull/2408/head
Arthur Campbell 10 months ago
parent
commit
f60d12c767
  1. 2
      app/frontend/styles/_data_box.scss
  2. 5
      app/presenters/homepage_presenter.rb
  3. 2
      spec/features/form/tasklist_page_spec.rb
  4. 2
      spec/presenters/homepage_presenter_spec.rb
  5. 87
      spec/requests/start_controller_spec.rb
  6. 2
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  7. 2
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

2
app/frontend/styles/_data_box.scss

@ -5,7 +5,7 @@
} }
.app-data-box-group { .app-data-box-group {
@include govuk-responsive-margin(4, "top") @include govuk-responsive-margin(4, "top");
} }
@media (min-width: 54.0625em) { @media (min-width: 54.0625em) {

5
app/presenters/homepage_presenter.rb

@ -1,5 +1,6 @@
class HomepagePresenter class HomepagePresenter
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
include CollectionTimeHelper
attr_reader :current_year_in_progress_lettings_data, :current_year_completed_lettings_data, :current_year_in_progress_sales_data, :current_year_completed_sales_data, :last_year_in_progress_lettings_data, :last_year_completed_lettings_data, :last_year_in_progress_sales_data, :last_year_completed_sales_data, :incomplete_schemes_data attr_reader :current_year_in_progress_lettings_data, :current_year_completed_lettings_data, :current_year_in_progress_sales_data, :current_year_completed_sales_data, :last_year_in_progress_lettings_data, :last_year_completed_lettings_data, :last_year_in_progress_sales_data, :last_year_completed_sales_data, :incomplete_schemes_data
@ -7,7 +8,7 @@ class HomepagePresenter
@user = user @user = user
@display_sales = should_display_sales? @display_sales = should_display_sales?
@in_crossover_period = FormHandler.instance.in_crossover_period? @in_crossover_period = FormHandler.instance.in_crossover_period?
@current_year = FormHandler.instance.current_lettings_form.start_date.year @current_year = current_collection_start_year
@current_year_in_progress_lettings_data = data_box_data(:lettings, @current_year, :in_progress) @current_year_in_progress_lettings_data = data_box_data(:lettings, @current_year, :in_progress)
@current_year_completed_lettings_data = data_box_data(:lettings, @current_year, :completed) @current_year_completed_lettings_data = data_box_data(:lettings, @current_year, :completed)
@current_year_in_progress_sales_data = data_box_data(:sales, @current_year, :in_progress) if display_sales? @current_year_in_progress_sales_data = data_box_data(:sales, @current_year, :in_progress) if display_sales?
@ -60,8 +61,6 @@ class HomepagePresenter
private private
def subheading_from_year(year) def subheading_from_year(year)
return "AAAAH" if year.nil?
"#{year} to #{year + 1} Logs" "#{year} to #{year + 1} Logs"
end end

2
spec/features/form/tasklist_page_spec.rb

@ -67,7 +67,7 @@ RSpec.describe "Task List" do
expect(page).to have_content("This log has not been started.") expect(page).to have_content("This log has not been started.")
end end
context "when testing completed subsection count" do describe "completed subsection count" do
let(:real_2021_2022_form) { Form.new("config/forms/2021_2022.json") } let(:real_2021_2022_form) { Form.new("config/forms/2021_2022.json") }
before do before do

2
spec/presenters/homepage_presenter_spec.rb

@ -148,7 +148,7 @@ RSpec.describe HomepagePresenter do
end end
end end
context "when testing the data collected and exposed by the presenter" do describe "the data collected and exposed by the presenter" do
context "with lettings logs" do context "with lettings logs" do
let(:type) { :lettings_log } let(:type) { :lettings_log }

87
spec/requests/start_controller_spec.rb

@ -32,7 +32,7 @@ RSpec.describe StartController, type: :request do
expect(page).to have_content("Welcome back") expect(page).to have_content("Welcome back")
end end
context "when testing the data displayed at the top of the home page" do describe "the data displayed at the top of the home page" do
let(:current_year) { FormHandler.instance.current_collection_start_year } let(:current_year) { FormHandler.instance.current_collection_start_year }
let(:in_crossover_period) { false } let(:in_crossover_period) { false }
@ -139,7 +139,7 @@ RSpec.describe StartController, type: :request do
end end
end end
context "when testing the links in the data boxes" do describe "the links in the data boxes" do
let(:user) { create(:user, :data_coordinator) } let(:user) { create(:user, :data_coordinator) }
let(:in_crossover_period) { true } let(:in_crossover_period) { true }
@ -148,76 +148,27 @@ RSpec.describe StartController, type: :request do
get root_path get root_path
end end
it "shows the correct links for in progress lettings" do [
type = "lettings" { type: "lettings", status: "in_progress" },
status = "in_progress" { type: "lettings", status: "completed" },
databoxes = all_databoxes(type, status) { type: "sales", status: "in_progress" },
{ type: "sales", status: "completed" },
expect(databoxes.count).to be 2 ].each do |test_case|
it "shows the correct links for #{test_case[:status]} #{test_case[:type]}" do
links = databoxes.map { |databox| link_from_databox databox } databoxes = all_databoxes(test_case[:type], test_case[:status])
expect(links.map(&:path)).to all eq lettings_logs_path
params = links.map { |link| CGI.parse(link.query) }
expect(params.map { |prms| prms["status[]"] }).to all eq [status]
expect(params.first["years[]"]).to eq [(current_year - 1).to_s]
expect(params.second["years[]"]).to eq [current_year.to_s]
end
it "shows the correct links for completed lettings" do
type = "lettings"
status = "completed"
databoxes = all_databoxes(type, status)
expect(databoxes.count).to be 2
links = databoxes.map { |databox| link_from_databox databox }
expect(links.map(&:path)).to all eq lettings_logs_path
params = links.map { |link| CGI.parse(link.query) }
expect(params.map { |prms| prms["status[]"] }).to all eq [status] expect(databoxes.count).to be 2
expect(params.first["years[]"]).to eq [(current_year - 1).to_s]
expect(params.second["years[]"]).to eq [current_year.to_s]
end
it "shows the correct links for in progress sales" do
type = "sales"
status = "in_progress"
databoxes = all_databoxes(type, status)
expect(databoxes.count).to be 2
links = databoxes.map { |databox| link_from_databox databox } links = databoxes.map { |databox| link_from_databox databox }
expect(links.map(&:path)).to all eq sales_logs_path expect(links.map(&:path)).to all eq send("#{test_case[:type]}_logs_path")
params = links.map { |link| CGI.parse(link.query) } params = links.map { |link| CGI.parse(link.query) }
expect(params.map { |prms| prms["status[]"] }).to all eq [status] expect(params.map { |prms| prms["status[]"] }).to all eq [test_case[:status]]
expect(params.first["years[]"]).to eq [(current_year - 1).to_s] expect(params.first["years[]"]).to eq [(current_year - 1).to_s]
expect(params.second["years[]"]).to eq [current_year.to_s] expect(params.second["years[]"]).to eq [current_year.to_s]
end end
it "shows the correct links for completed sales" do
type = "sales"
status = "completed"
databoxes = all_databoxes(type, status)
expect(databoxes.count).to be 2
links = databoxes.map { |databox| link_from_databox databox }
expect(links.map(&:path)).to all eq sales_logs_path
params = links.map { |link| CGI.parse(link.query) }
expect(params.map { |prms| prms["status[]"] }).to all eq [status]
expect(params.first["years[]"]).to eq [(current_year - 1).to_s]
expect(params.second["years[]"]).to eq [current_year.to_s]
end end
it "shows the correct links for incomplete schemes" do it "shows the correct links for incomplete schemes" do
@ -237,7 +188,7 @@ RSpec.describe StartController, type: :request do
end end
end end
context "when testing the counts displayed" do describe "the counts displayed" do
let(:in_crossover_period) { true } let(:in_crossover_period) { true }
let(:org_1) { create(:organisation) } let(:org_1) { create(:organisation) }
let(:org_2) { create(:organisation) } let(:org_2) { create(:organisation) }

2
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -107,7 +107,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end end
end end
context "when testing valid/invalid attributes" do describe "valid/invalid attributes" do
let(:valid_attributes) do let(:valid_attributes) do
{ {
bulk_upload:, bulk_upload:,

2
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -125,7 +125,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
end end
context "when testing valid/invalid attributes" do describe "valid/invalid attributes" do
let(:valid_attributes) do let(:valid_attributes) do
{ {
bulk_upload:, bulk_upload:,

Loading…
Cancel
Save