Skip to content

Commit

Permalink
Change static factory attrs to dynamic
Browse files Browse the repository at this point in the history
FactoryBot 5.0 will no longer support static factory attributes, so we
need to update our factories in advance to silence the deprecation
warnings.
  • Loading branch information
fastjames committed Aug 30, 2018
1 parent cdcd94e commit ba896d6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
factory :installment_detail, class: 'SolidusSubscriptions::InstallmentDetail' do
installment

trait(:success) { success true }
trait(:success) {
success { true }
}
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FactoryBot.define do
factory :installment, class: 'SolidusSubscriptions::Installment' do
transient { subscription_traits [] }
transient {
subscription_traits { [] }
}
subscription { build :subscription, :with_line_item, *subscription_traits }

trait :failed do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FactoryBot.define do
factory :subscription_line_item, class: 'SolidusSubscriptions::LineItem' do
subscribable_id { create(:variant, subscribable: true).id }
quantity 1
interval_length 1
interval_units :month
quantity { 1 }
interval_length { 1 }
interval_units { :month }

association :spree_line_item, factory: :line_item

trait :with_subscription do
transient do
subscription_traits []
subscription_traits { [] }
end

subscription { build :subscription, *subscription_traits }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
factory :line_item do
trait :with_subscription_line_items do
transient do
n_subscription_line_items 1
n_subscription_line_items { 1 }
end

subscription_line_items do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
factory :order do
trait :with_subscription_line_items do
transient do
n_line_items 1
n_line_items { 1 }
end

line_items do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FactoryBot.define do
factory :subscription, class: 'SolidusSubscriptions::Subscription' do
store
interval_length 1
interval_units :month
interval_length { 1 }
interval_units { :month }

user do
create(:user, :subscription_user).tap do |user|
Expand All @@ -12,7 +12,7 @@

trait :with_line_item do
transient do
line_item_traits []
line_item_traits { [] }
end

line_items { build_list :subscription_line_item, 1, *line_item_traits }
Expand All @@ -37,7 +37,11 @@
state { 'pending_cancellation' }
end

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

0 comments on commit ba896d6

Please sign in to comment.