From 595891ac6a7f6641b04f5cd4e1ecaa21c0ed7eb6 Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 11 Dec 2020 10:58:20 -0600 Subject: Update cancel method on subscription to respect minimum date Previously, the cancel method would check if the minimum cancellation date minus the current day is in the future before cancelling. However, that adds one day to whatever minimum cancellation date that you set - if you set one day, you would expect the user not to be able to cancel on the day that the subscription ships, but because the method checks if the date is in the future, the user can't cancel the day of, or the day before. This checks if the date is in the future OR if it's today, which removes the added day from the minimum_cancellation_notice. Also this sets the default to 0.days, as 1.day is pretty arbitrary Lastly, this locks canonical-rails down to 0.2.9, because Solidus still uses the `whitelisted_attributes` method, which was renamed in 0.2.10 --- lib/solidus_subscriptions/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/solidus_subscriptions') diff --git a/lib/solidus_subscriptions/configuration.rb b/lib/solidus_subscriptions/configuration.rb index f09740b..52c8fd4 100644 --- a/lib/solidus_subscriptions/configuration.rb +++ b/lib/solidus_subscriptions/configuration.rb @@ -43,7 +43,7 @@ module SolidusSubscriptions end def minimum_cancellation_notice - @minimum_cancellation_notice ||= 1.day + @minimum_cancellation_notice ||= 0.days end def processing_queue -- cgit v1.2.3