Skip to content

Commit

Permalink
Add Cycles::EndOf#last_completed
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowd committed Sep 2, 2024
1 parent 6d8e521 commit fa60729
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions lib/sof/cycles/end_of.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def to_s
"#{volume}x by #{final_date.to_fs(:american)}"
end

# Always returns the from_date
def last_completed(_) = from_date.to_date

# Returns the expiration date for the cycle
#
# @param [nil] _ Unused parameter, maintained for compatibility
Expand Down
13 changes: 7 additions & 6 deletions spec/sof/cycles/end_of_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module SOF
let(:notation) { "V2E18MF#{from_date}" }
let(:anchor) { nil }

let(:end_date) { (from_date.to_date + 17.months).end_of_month }
let(:from_date) { "2020-01-01" }
let(:end_date) { (from_date + 17.months).end_of_month }
let(:from_date) { "2020-01-01".to_date }

let(:completed_dates) { [] }

Expand Down Expand Up @@ -39,6 +39,7 @@ module SOF
it_behaves_like "#as_json returns the notation"
it_behaves_like "it computes #final_date(given)",
given: nil, returns: ("2020-01-01".to_date + 17.months).end_of_month
it_behaves_like "last_completed is", :from_date

describe "#covered_dates" do
let(:completed_dates) do
Expand All @@ -51,10 +52,10 @@ module SOF
too_late_date
]
end
let(:recent_date) { from_date.to_date + 17.months }
let(:middle_date) { from_date.to_date + 2.months }
let(:early_date) { from_date.to_date + 1.month }
let(:too_early_date) { from_date.to_date - 1.day }
let(:recent_date) { from_date + 17.months }
let(:middle_date) { from_date + 2.months }
let(:early_date) { from_date + 1.month }
let(:too_early_date) { from_date - 1.day }
let(:too_late_date) { end_date + 1.day }

let(:anchor) { "2021-06-29".to_date }
Expand Down

0 comments on commit fa60729

Please sign in to comment.