Browse Source

Do not display deleted schemes in homepage count (#2458)

pull/2467/head
kosiakkatrina 7 months ago committed by GitHub
parent
commit
dbca9323ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/presenters/homepage_presenter.rb
  2. 16
      spec/requests/start_controller_spec.rb

2
app/presenters/homepage_presenter.rb

@ -20,7 +20,7 @@ class HomepagePresenter
@last_year_completed_sales_data = data_box_data(:sales, @last_year, :completed) if display_sales?
if display_schemes?
@incomplete_schemes_data = {
count: @user.schemes.incomplete.count,
count: @user.schemes.visible.incomplete.count,
text: data_box_text(type: :schemes, status: :incomplete),
path: schemes_path(status: [:incomplete], owning_organisation_select: "all"),
}

16
spec/requests/start_controller_spec.rb

@ -262,6 +262,22 @@ RSpec.describe StartController, type: :request do
counts = databoxes.map { |databox| count_from_databox databox }
expect(counts).to eq [0, 0]
end
it "shows the correct count for schemes" do
completed_schemes_count = 3
incomplete_schemes_count = 2
create_list(:scheme, completed_schemes_count, :incomplete, owning_organisation: coordinator.organisation)
create_list(:scheme, incomplete_schemes_count, :incomplete, owning_organisation: coordinator.organisation, discarded_at: Time.zone.yesterday)
get root_path
type = "schemes"
status = "incomplete"
databoxes = all_databoxes(type, status)
count = count_from_databox(databoxes.first)
expect(count).to eq(completed_schemes_count)
end
end
context "and logged in as a support user" do

Loading…
Cancel
Save