summaryrefslogtreecommitdiff
path: root/lib/solidus_subscriptions/testing_support
diff options
context:
space:
mode:
Diffstat (limited to 'lib/solidus_subscriptions/testing_support')
-rw-r--r--lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb2
-rw-r--r--lib/solidus_subscriptions/testing_support/factories/installment_factory.rb10
-rw-r--r--lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb18
3 files changed, 29 insertions, 1 deletions
diff --git a/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb b/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb
index e32df4b..26eb087 100644
--- a/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb
+++ b/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb
@@ -1,5 +1,7 @@
FactoryGirl.define do
factory :installment_detail, class: 'SolidusSubscriptions::InstallmentDetail' do
installment
+
+ trait(:success) { success true }
end
end
diff --git a/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb b/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb
index 59d9d5e..ec10e22 100644
--- a/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb
+++ b/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb
@@ -2,5 +2,15 @@ FactoryGirl.define do
factory :installment, class: 'SolidusSubscriptions::Installment' do
transient { subscription_traits [] }
subscription { build :subscription, :with_line_item, *subscription_traits }
+
+ trait :failed do
+ actionable_date { Time.zone.yesterday }
+ details { build_list(:installment_detail, 1, installment: @instance) }
+ end
+
+ trait :success do
+ association :order, factory: :completed_order_with_totals
+ details { build_list(:installment_detail, 1, :success, installment: @instance) }
+ end
end
end
diff --git a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
index 420baed..92ecb77 100644
--- a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
+++ b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
@@ -1,6 +1,9 @@
FactoryGirl.define do
factory :subscription, class: 'SolidusSubscriptions::Subscription' do
- user
+ user do
+ ccs = build_list(:credit_card, 1, gateway_customer_profile_id: 'BGS-123', default: true)
+ build :user, credit_cards: ccs
+ end
trait :with_line_item do
transient do
@@ -9,5 +12,18 @@ FactoryGirl.define do
line_item { build :subscription_line_item, *line_item_traits }
end
+
+ trait :actionable do
+ with_line_item
+ actionable_date { Time.zone.now.yesterday }
+ end
+
+ trait :not_actionable do
+ with_line_item
+ actionable_date { Time.zone.now.tomorrow }
+ end
+
+ trait(:canceled) { state 'canceled' }
+ trait(:inactive) { state 'inactive' }
end
end