Skip to content

Commit

Permalink
Changes made by linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin-Couey committed Dec 12, 2024
1 parent 2217817 commit a66984d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/manufacturer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
13 changes: 6 additions & 7 deletions spec/models/manufacturer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -80,7 +80,6 @@
expect(@mfg_by_donation).to match_array([@mfg1, @mfg2])
end
end

end

context "Private Methods" do
Expand Down

0 comments on commit a66984d

Please sign in to comment.