diff --git a/app/models/manufacturer.rb b/app/models/manufacturer.rb index 4c75fe81de..8218de5f12 100644 --- a/app/models/manufacturer.rb +++ b/app/models/manufacturer.rb @@ -26,7 +26,7 @@ def volume donations.joins(:line_items).sum(:quantity) end - def self.by_donation_date(count=10, date_range=nil) + def self.by_donation_date(count = 10, date_range = nil) # selects manufacturers that have donation qty > 0 in the provided date range # and sorts them by the date of the most recent donation joins(donations: :line_items).where(donations: { issued_at: date_range }) diff --git a/spec/models/manufacturer_spec.rb b/spec/models/manufacturer_spec.rb index 386b4f650b..a433139a16 100644 --- a/spec/models/manufacturer_spec.rb +++ b/spec/models/manufacturer_spec.rb @@ -51,13 +51,13 @@ before(:all) do # Prepare manufacturers with donations for tests today = Time.zone.today - from = (today-1.month).beginning_of_day + from = (today - 1.month).beginning_of_day to = today.end_of_day dates_in_order = [ today, - today-1.day, - today-2.day, - today-3.day, + today - 1.day, + today - 2.days, + today - 3.days ] @mfg1 = create(:manufacturer) @@ -66,9 +66,9 @@ @mfg2 = create(:manufacturer) create(:donation, :with_items, item_quantity: 5, source: Donation::SOURCES[:manufacturer], manufacturer: @mfg2, issued_at: dates_in_order[1]) create(:donation, :with_items, item_quantity: 5, source: Donation::SOURCES[:manufacturer], manufacturer: @mfg1, issued_at: dates_in_order[2]) - mfg_no_donations = create(:manufacturer) + create(:manufacturer) mfg_no_in_range = create(:manufacturer) - create(:donation, :with_items, item_quantity: 5, source: Donation::SOURCES[:manufacturer], manufacturer: mfg_no_in_range, issued_at: today-1.year) + create(:donation, :with_items, item_quantity: 5, source: Donation::SOURCES[:manufacturer], manufacturer: mfg_no_in_range, issued_at: today - 1.year) @mfg_by_donation = Manufacturer.all.by_donation_date(10, from..to) end @@ -80,7 +80,6 @@ expect(@mfg_by_donation).to match_array([@mfg1, @mfg2]) end end - end context "Private Methods" do