summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb5
-rw-r--r--spec/lib/solidus_subscriptions/processor_spec.rb7
-rw-r--r--spec/models/solidus_subscriptions/checkout_spec.rb11
3 files changed, 11 insertions, 12 deletions
diff --git a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
index 222f9ef..036b4c2 100644
--- a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
+++ b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
@@ -5,8 +5,9 @@ FactoryGirl.define do
interval_units :month
user do
- ccs = build_list(:credit_card, 1, gateway_customer_profile_id: 'BGS-123', default: true)
- build :user, :subscription_user, credit_cards: ccs
+ create(:user, :subscription_user).tap do |user|
+ create(:credit_card, gateway_customer_profile_id: 'BGS-123', user: user, default: true)
+ end
end
trait :with_line_item do
diff --git a/spec/lib/solidus_subscriptions/processor_spec.rb b/spec/lib/solidus_subscriptions/processor_spec.rb
index a21d22f..bccff78 100644
--- a/spec/lib/solidus_subscriptions/processor_spec.rb
+++ b/spec/lib/solidus_subscriptions/processor_spec.rb
@@ -4,9 +4,10 @@ RSpec.describe SolidusSubscriptions::Processor, :checkout do
include ActiveJob::TestHelper
around { |e| perform_enqueued_jobs { e.run } }
- let(:user) do
- ccs = build_list(:credit_card, 1, gateway_customer_profile_id: 'BGS-123', default: true)
- build :user, :subscription_user, credit_cards: ccs
+ let!(:user) do
+ create(:user, :subscription_user).tap do |user|
+ create(:credit_card, gateway_customer_profile_id: 'BGS-123', user: user, default: true)
+ end
end
let!(:actionable_subscriptions) { create_list(:subscription, 2, :actionable, user: user) }
diff --git a/spec/models/solidus_subscriptions/checkout_spec.rb b/spec/models/solidus_subscriptions/checkout_spec.rb
index 30d6e40..5e8cc0b 100644
--- a/spec/models/solidus_subscriptions/checkout_spec.rb
+++ b/spec/models/solidus_subscriptions/checkout_spec.rb
@@ -4,8 +4,9 @@ RSpec.describe SolidusSubscriptions::Checkout do
let(:checkout) { described_class.new(installments) }
let(:root_order) { create :completed_order_with_pending_payment }
let(:subscription_user) do
- ccs = build_list(:credit_card, 1, gateway_customer_profile_id: 'BGS-123', default: true)
- create :user, :subscription_user, credit_cards: ccs
+ create(:user, :subscription_user).tap do |user|
+ create(:credit_card, gateway_customer_profile_id: 'BGS-123', user: user, default: true)
+ end
end
let(:installments) { create_list(:installment, 2, installment_traits) }
@@ -138,13 +139,9 @@ RSpec.describe SolidusSubscriptions::Checkout do
end
context 'the payment fails' do
- let(:credit_card) { create(:credit_card, default: true) }
+ let!(:credit_card) { create(:credit_card, user: checkout.user, default: true) }
let(:expected_date) { (DateTime.current + SolidusSubscriptions::Config.reprocessing_interval).beginning_of_minute }
- before do
- checkout.user.credit_cards << credit_card
- end
-
it { is_expected.to be_nil }
it 'marks all of the installments as failed' do