diff options
author | Brendan Deere <brendan@stembolt.com> | 2016-09-22 11:19:32 -0700 |
---|---|---|
committer | Brendan Deere <brendan@stembolt.com> | 2016-09-22 11:44:00 -0700 |
commit | da3ca246d6cb962108c28c68311df86403e234f3 (patch) | |
tree | ef81147bac8a9f5c020b6025b7bd9d67a2ec1170 /lib/solidus_subscriptions/testing_support | |
parent | ebc71262df97c3ab4f06bfb37fc2a70f85a1dc49 (diff) |
Move factories to testing support
So that parent applications can use them
Diffstat (limited to 'lib/solidus_subscriptions/testing_support')
7 files changed, 81 insertions, 0 deletions
diff --git a/lib/solidus_subscriptions/testing_support/factories.rb b/lib/solidus_subscriptions/testing_support/factories.rb new file mode 100644 index 0000000..6cafa63 --- /dev/null +++ b/lib/solidus_subscriptions/testing_support/factories.rb @@ -0,0 +1,5 @@ +require 'factory_girl' +require 'spree/testing_support/factories' + +factory_path = "#{File.dirname(__FILE__)}/factories/**/*_factory.rb" +Dir[factory_path].each { |f| require File.expand_path(f) } diff --git a/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb b/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb new file mode 100644 index 0000000..e32df4b --- /dev/null +++ b/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :installment_detail, class: 'SolidusSubscriptions::InstallmentDetail' do + installment + end +end diff --git a/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb b/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb new file mode 100644 index 0000000..59d9d5e --- /dev/null +++ b/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :installment, class: 'SolidusSubscriptions::Installment' do + transient { subscription_traits [] } + subscription { build :subscription, :with_line_item, *subscription_traits } + end +end diff --git a/lib/solidus_subscriptions/testing_support/factories/line_item_factory.rb b/lib/solidus_subscriptions/testing_support/factories/line_item_factory.rb new file mode 100644 index 0000000..af93720 --- /dev/null +++ b/lib/solidus_subscriptions/testing_support/factories/line_item_factory.rb @@ -0,0 +1,17 @@ +FactoryGirl.define do + factory :subscription_line_item, class: 'SolidusSubscriptions::LineItem' do + subscribable_id { create(:variant, subscribable: true).id } + quantity 1 + interval 30.days + + association :spree_line_item, factory: :line_item + + trait :with_subscription do + transient do + subscription_traits [] + end + + subscription { build :subscription, *subscription_traits } + end + end +end diff --git a/lib/solidus_subscriptions/testing_support/factories/spree/line_item_factory.rb b/lib/solidus_subscriptions/testing_support/factories/spree/line_item_factory.rb new file mode 100644 index 0000000..afa6588 --- /dev/null +++ b/lib/solidus_subscriptions/testing_support/factories/spree/line_item_factory.rb @@ -0,0 +1,17 @@ +FactoryGirl.modify do + factory :line_item do + trait :with_subscription_line_items do + transient do + n_subscription_line_items 1 + end + + subscription_line_items do + build_list( + :subscription_line_item, + n_subscription_line_items, + spree_line_item: @instance + ) + end + end + end +end diff --git a/lib/solidus_subscriptions/testing_support/factories/spree/order_factory.rb b/lib/solidus_subscriptions/testing_support/factories/spree/order_factory.rb new file mode 100644 index 0000000..a2ce307 --- /dev/null +++ b/lib/solidus_subscriptions/testing_support/factories/spree/order_factory.rb @@ -0,0 +1,18 @@ +FactoryGirl.modify do + factory :order do + trait :with_subscription_line_items do + transient do + n_line_items 1 + end + + line_items do + build_list( + :line_item, + n_line_items, + :with_subscription_line_items, + order: @instance + ) + end + 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 new file mode 100644 index 0000000..420baed --- /dev/null +++ b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb @@ -0,0 +1,13 @@ +FactoryGirl.define do + factory :subscription, class: 'SolidusSubscriptions::Subscription' do + user + + trait :with_line_item do + transient do + line_item_traits [] + end + + line_item { build :subscription_line_item, *line_item_traits } + end + end +end |