diff options
author | Brendan Deere <brendan@stembolt.com> | 2016-09-23 15:04:11 -0700 |
---|---|---|
committer | Brendan Deere <brendan@stembolt.com> | 2016-09-23 15:46:10 -0700 |
commit | 20a87913c322e23bc142113d727ef7a4a419432c (patch) | |
tree | d95007d5e4b91f77d6aec5ec9e66d05e70956c36 /lib | |
parent | 17f9f895c77cc27c08c1c1c34b82d4a34c3a226c (diff) |
Add some improved factories
Add some traits for the different installment and subscriptions states
Subscriptions now initialize with user that owns a credit card
Diffstat (limited to 'lib')
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 |