From 6cb8bb2fc3ef3b947550698db2f539c39db1c199 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 2 Mar 2020 22:07:20 +0100 Subject: [PATCH] Add missing :cc_type attribute to default :credit_card factory Fixes 5 specs, including: 11) Spree::CreditCardsController#update when the specified credit card is found and the card is owned by the user when the update completes successfully renders a serialized copy of the updated card Failure/Error: object.cc_type.capitalize NoMethodError: undefined method `capitalize' for nil:NilClass # ./app/serializers/api/credit_card_serializer.rb:6:in `brand' # (eval):4:in `_fast_attributes' # ./app/controllers/spree/credit_cards_controller.rb:26:in `update' # ./spec/controllers/spree/credit_cards_controller_spec.rb:100:in `block (7 levels) in ' # ./spec/controllers/spree/credit_cards_controller_spec.rb:100:in `block (6 levels) in ' # ------------------ # --- Caused by: --- # NoMethodError: # undefined method `capitalize' for nil:NilClass # ./app/serializers/api/credit_card_serializer.rb:6:in `brand' --- spec/factories.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/factories.rb b/spec/factories.rb index 8474d44a6e..40de71effa 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -164,6 +164,10 @@ FactoryBot.modify do country { Spree::Country.find_by name: 'Australia' || Spree::Country.first } end + factory :credit_card do + cc_type 'visa' + end + factory :payment do transient do distributor {