From cbd966d3b6885472d3b79be97dd86961587133c6 Mon Sep 17 00:00:00 2001 From: John Dowd Date: Mon, 2 Sep 2024 08:00:41 -0400 Subject: [PATCH 1/4] EndOf#last_completed handles dormant state --- lib/sof/cycles/end_of.rb | 2 +- spec/sof/cycles/end_of_spec.rb | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/sof/cycles/end_of.rb b/lib/sof/cycles/end_of.rb index ac9498d..0326b92 100644 --- a/lib/sof/cycles/end_of.rb +++ b/lib/sof/cycles/end_of.rb @@ -25,7 +25,7 @@ def to_s end # Always returns the from_date - def last_completed(_) = from_date.to_date + def last_completed(_ = nil) = from_date&.to_date # Returns the expiration date for the cycle # diff --git a/spec/sof/cycles/end_of_spec.rb b/spec/sof/cycles/end_of_spec.rb index 61f8098..fb614c9 100644 --- a/spec/sof/cycles/end_of_spec.rb +++ b/spec/sof/cycles/end_of_spec.rb @@ -39,7 +39,20 @@ 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 "#last_completed" do + context "with an activated cycle" do + it_behaves_like "last_completed is", :from_date + end + + context "with a dormant cycle" do + let(:notation) { "V2E18M" } + + it "returns nil" do + expect(cycle.last_completed).to be_nil + end + end + end describe "#covered_dates" do let(:completed_dates) do From 34923fe86fc4843a3e9bdcc8f03c39d170b64599 Mon Sep 17 00:00:00 2001 From: John Dowd Date: Mon, 2 Sep 2024 08:07:11 -0400 Subject: [PATCH 2/4] Add Dormant#last_completed --- spec/sof/cycles/dormant_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/sof/cycles/dormant_spec.rb b/spec/sof/cycles/dormant_spec.rb index c9d778b..bda1d39 100644 --- a/spec/sof/cycles/dormant_spec.rb +++ b/spec/sof/cycles/dormant_spec.rb @@ -29,6 +29,20 @@ module SOF it_behaves_like "#kind returns", :dormant + describe "#last_completed" do + context "with a dormant Within cycle" do + it "returns nil" do + expect(within_cycle.last_completed(completed_dates)).to eq recent_date + end + end + + context "with a dormant EndOf cycle" do + it "returns nil" do + expect(end_of_cycle.last_completed).to be_nil + end + end + end + describe "#recurring?" do it "does not repeat" do expect(within_cycle).not_to be_recurring From 7e8d23bd1db5038d86c80393863d2c67a90706f2 Mon Sep 17 00:00:00 2001 From: John Dowd Date: Mon, 2 Sep 2024 08:16:06 -0400 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b593888..51fd58c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.1.5] - Unreleased +### Fixed + +- `Cycle#last_completed` works for dormant cycles too + ## [0.1.4] - 2024-09-02 ### Added From e0508c4d62c04305179b8ec0635ca5a4a2b6b827 Mon Sep 17 00:00:00 2001 From: John Dowd Date: Mon, 2 Sep 2024 08:16:13 -0400 Subject: [PATCH 4/4] Finalize the changelog for version 0.1.5 on 2024-09-02 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51fd58c..6e17c49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.1.5] - Unreleased +## [0.1.5] - 2024-09-02 ### Fixed