summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Desantis <desa.alessandro@gmail.com>2020-06-17 13:32:12 +0200
committerAlessandro Desantis <desa.alessandro@gmail.com>2020-06-17 13:51:24 +0200
commit501cb584beb079bc9e4f967b940c1d3e7ea9c01f (patch)
tree2fa1d555e724903a997b539e77f4e417e98e3ae5
parent1c5c52fb90cb8080f4cd8881d2816ee3a08d2306 (diff)
Create :with_shipping_address and :with_billing_address traits
-rw-r--r--lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb6
-rw-r--r--spec/lib/solidus_subscriptions/processor_spec.rb2
-rw-r--r--spec/models/solidus_subscriptions/line_item_spec.rb4
3 files changed, 8 insertions, 4 deletions
diff --git a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
index cdbea1e..87fe75d 100644
--- a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
+++ b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
@@ -20,10 +20,14 @@ FactoryBot.define do
line_items { build_list :subscription_line_item, 1, *line_item_traits }
end
- trait :with_address do
+ 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 }
diff --git a/spec/lib/solidus_subscriptions/processor_spec.rb b/spec/lib/solidus_subscriptions/processor_spec.rb
index 9f18e58..f88af01 100644
--- a/spec/lib/solidus_subscriptions/processor_spec.rb
+++ b/spec/lib/solidus_subscriptions/processor_spec.rb
@@ -100,7 +100,7 @@ RSpec.describe SolidusSubscriptions::Processor, :checkout do
context 'the subscriptions have different shipping addresses' do
let!(:sub_to_different_address) do
- create(:subscription, :actionable, :with_address, user: user)
+ create(:subscription, :actionable, :with_shipping_address, user: user)
end
it 'creates an order for each shipping address' do
diff --git a/spec/models/solidus_subscriptions/line_item_spec.rb b/spec/models/solidus_subscriptions/line_item_spec.rb
index 7ca2475..0728f4d 100644
--- a/spec/models/solidus_subscriptions/line_item_spec.rb
+++ b/spec/models/solidus_subscriptions/line_item_spec.rb
@@ -81,9 +81,9 @@ RSpec.describe SolidusSubscriptions::LineItem, type: :model do
end
context 'with an associated subscription' do
- context 'the associated subscription has an address' do
+ context 'the associated subscription has a shipping address' do
let(:line_item) do
- create(:subscription_line_item, :with_subscription, subscription_traits: [:with_address])
+ create(:subscription_line_item, :with_subscription, subscription_traits: [:with_shipping_address])
end
it 'uses the subscription shipping address' do