File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ def total_received_from_product_drives(range = selected_range)
1616 number_with_delimiter total_received_from_product_drives_unformatted ( range )
1717 end
1818
19+ def total_number_of_drives ( range = selected_range )
20+ formatted_range = format_date_range_to_iso ( range )
21+ current_organization . product_drives . within_date_range ( formatted_range ) . count
22+ end
23+
1924 private
2025
2126 def total_received_donations_unformatted ( range = selected_range )
@@ -25,4 +30,8 @@ def total_received_donations_unformatted(range = selected_range)
2530 def total_received_from_product_drives_unformatted ( range = selected_range )
2631 LineItem . active . where ( itemizable : current_organization . donations . by_source ( :product_drive ) . during ( range ) ) . sum ( :quantity )
2732 end
33+
34+ def format_date_range_to_iso ( range )
35+ "#{ range . begin . to_date . iso8601 } - #{ range . end . to_date . iso8601 } "
36+ end
2837end
Original file line number Diff line number Diff line change 1010 footer: link_to("See more...", product_drives_path),
1111) do %>
1212
13+ <h3 class ="text-center ">
14+ < span class ="total_drives ">
15+ <%= total_number_of_drives %>
16+ </ span > drives active
17+ <%= @selected_date_range_label %>
18+ </ h3 >
1319 < h3 class ="text-center ">
1420 < span class ="total_received_donations ">
1521 <%= total_received_from_product_drives %>
Original file line number Diff line number Diff line change 3131 end
3232
3333 factory :product_drive_donation do
34- product_drive
34+ product_drive { build ( :product_drive ) }
3535 product_drive_participant
3636 source { Donation ::SOURCES [ :product_drive ] }
37+
38+ after ( :build ) do |donation |
39+ donation . product_drive . start_date = donation . issued_at
40+ donation . product_drive . end_date = donation . issued_at
41+ end
3742 end
3843
3944 factory :donation_site_donation do
Original file line number Diff line number Diff line change 4646 it "shows the correct total and links" do
4747 expect ( response . body ) . to match ( %r{<span class="total_received_donations">\s *14\s *</span>} )
4848 expect ( response . body ) . to match ( %r{<span class="total_money_raised">\s *\$ 24.00\s *</span>} )
49+ expect ( response . body ) . to match ( %r{<span class="total_drives">\s *2\s *</span>} )
4950 end
5051 end
5152
5455 it "shows the correct total and links" do
5556 expect ( response . body ) . to match ( %r{<span class="total_received_donations">\s *16\s *</span>} )
5657 expect ( response . body ) . to match ( %r{<span class="total_money_raised">\s *\$ 24.00\s *</span>} )
58+ expect ( response . body ) . to match ( %r{<span class="total_drives">\s *2\s *</span>} )
5759 end
5860 end
5961
6264 it "shows the correct total and links" do
6365 expect ( response . body ) . to match ( %r{<span class="total_received_donations">\s *122\s *</span>} )
6466 expect ( response . body ) . to match ( %r{<span class="total_money_raised">\s *\$ 24.00\s *</span>} )
67+ expect ( response . body ) . to match ( %r{<span class="total_drives">\s *2\s *</span>} )
6568 end
6669 end
6770
7073 it "shows the correct total and links" do
7174 expect ( response . body ) . to match ( %r{<span class="total_received_donations">\s *248\s *</span>} )
7275 expect ( response . body ) . to match ( %r{<span class="total_money_raised">\s *\$ 48.00\s *</span>} )
76+ expect ( response . body ) . to match ( %r{<span class="total_drives">\s *4\s *</span>} )
7377 end
7478 end
7579
7882 it "shows the correct total and links" do
7983 expect ( response . body ) . to match ( %r{<span class="total_received_donations">\s *422\s *</span>} )
8084 expect ( response . body ) . to match ( %r{<span class="total_money_raised">\s *\$ 120.00\s *</span>} )
85+ expect ( response . body ) . to match ( %r{<span class="total_drives">\s *10\s *</span>} )
8186 end
8287 end
8388 end
You can’t perform that action at this time.
0 commit comments