Skip to content

Commit

Permalink
Merge pull request #4 from solidusio-contrib/allow_retries_to_be_disa…
Browse files Browse the repository at this point in the history
…bled

Allow Failed installments to not be reprocessed
  • Loading branch information
qr8r authored Feb 3, 2017
2 parents 003cf2e + a745113 commit da0931d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apidoc/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ behaviour of the gem:
SolidusSubscriptions::Config.default_gateway = my_gateway

# Defines how long the system will wait before allowing a failed installment to
# be reprocessed by the `Processor`
# be reprocessed by the `Processor`. Set to nil to stop reprocessing failedx
# installments
SolidusSubscriptions::Config.reprocessing_interval = 1.days

# Maximum number of times a user can skip their subscription before it
Expand Down
1 change: 1 addition & 0 deletions app/models/solidus_subscriptions/installment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def advance_actionable_date!
end

def next_actionable_date
return if Config.reprocessing_interval.nil?
(DateTime.current + Config.reprocessing_interval).beginning_of_minute
end
end
Expand Down
16 changes: 16 additions & 0 deletions spec/models/solidus_subscriptions/installment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@
actionable_date = installment.reload.actionable_date
expect(actionable_date).to eq expected_date
end

context 'the reprocessing interval is set to nil' do
around do |e|
interval, SolidusSubscriptions::Config.reprocessing_interval = [SolidusSubscriptions::Config.reprocessing_interval, nil]

e.run

SolidusSubscriptions::Config.reprocessing_interval = interval
end

it 'does not advance the installment actionable_date' do
subject
actionable_date = installment.reload.actionable_date
expect(actionable_date).to be_nil
end
end
end

describe '#unfulfilled?' do
Expand Down

0 comments on commit da0931d

Please sign in to comment.