Sha256: f721bd64197192b61059583994db7499c7f0460e13ad32c55b8ea53007cff76d

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

FactoryGirl.define do
  factory :subscription, class: 'SolidusSubscriptions::Subscription' do
    store
    interval_length 1
    interval_units :month

    user do
      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
      transient do
        line_item_traits []
      end

      line_items { build_list :subscription_line_item, 1, *line_item_traits }
    end

    trait :with_address do
      association :shipping_address, factory: :address
    end

    trait :actionable do
      with_line_item
      actionable_date { Time.zone.now.yesterday.beginning_of_minute }
    end

    trait :not_actionable do
      with_line_item
      actionable_date { Time.zone.now.tomorrow.beginning_of_minute }
    end

    trait(:pending_cancellation) do
      actionable
      state { 'pending_cancellation' }
    end

    trait(:canceled) { state 'canceled' }
    trait(:inactive) { state 'inactive' }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_subscriptions-alpha-0.0.5 lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
solidus_subscriptions-alpha-0.0.3 lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
solidus_subscriptions-alpha-0.0.2 lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
solidus_subscriptions-alpha-0.0.1 lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb