blob: 2898d369c3d4129c283fc60c0aad8f41ed9585bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# frozen_string_literal: true
FactoryBot.define do
factory :subscription, class: 'SolidusSubscriptions::Subscription' do
store
interval_length { 1 }
interval_units { :month }
user do
new_user = create(:user, :subscription_user)
card = create(:credit_card, gateway_customer_profile_id: 'BGS-123', user: new_user)
wallet_payment_source = new_user.wallet.add(card)
new_user.wallet.default_wallet_payment_source = wallet_payment_source
new_user
end
trait :with_line_item do
transient do
line_item_traits { [] }
end
line_items { [association(:subscription_line_item, *line_item_traits)] }
end
trait :with_shipping_address do
association :shipping_address, factory: :address
end
trait :with_billing_address do
association :billing_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
|