diff options
-rw-r--r-- | lib/solidus_subscriptions/processor.rb | 2 | ||||
-rw-r--r-- | spec/lib/solidus_subscriptions/processor_spec.rb | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/solidus_subscriptions/processor.rb b/lib/solidus_subscriptions/processor.rb index ef3ec59..96717cc 100644 --- a/lib/solidus_subscriptions/processor.rb +++ b/lib/solidus_subscriptions/processor.rb @@ -58,7 +58,7 @@ module SolidusSubscriptions def build_jobs users.map do |user| installemts_by_address_and_user = installments(user).group_by do |i| - i.subscription.shipping_address_id + [i.subscription.shipping_address_id, i.subscription.billing_address_id] end installemts_by_address_and_user.values.each do |grouped_installments| diff --git a/spec/lib/solidus_subscriptions/processor_spec.rb b/spec/lib/solidus_subscriptions/processor_spec.rb index f88af01..96ac9f9 100644 --- a/spec/lib/solidus_subscriptions/processor_spec.rb +++ b/spec/lib/solidus_subscriptions/processor_spec.rb @@ -107,6 +107,16 @@ RSpec.describe SolidusSubscriptions::Processor, :checkout do expect { subject }.to change { Spree::Order.complete.count }.by 2 end end + + context 'the subscriptions have different billing addresses' do + let!(:sub_to_different_address) do + create(:subscription, :actionable, :with_billing_address, user: user) + end + + it 'creates an order for each billing address' do + expect { subject }.to change { Spree::Order.complete.count }.by 2 + end + end end describe '.run' do |