Skip to content

Commit

Permalink
please the hound gods
Browse files Browse the repository at this point in the history
  • Loading branch information
peterberkenbosch committed Jul 26, 2016
1 parent 42b2d61 commit 3e4cbf2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/app/models/spree/wallet_payment_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Spree::WalletPaymentSource < ActiveRecord::Base
validate :check_for_payment_source_class

private

def check_for_payment_source_class
if !payment_source.is_a?(Spree::PaymentSource)
errors.add(:payment_source, :has_to_be_payment_source_class)
Expand Down
4 changes: 1 addition & 3 deletions core/spec/models/spree/wallet_payment_source_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
subject { Spree::WalletPaymentSource }

context "validation" do

it "errors when `payment_source` is not a `Spree::PaymentSource`" do
invalid_payment_source_attrs = {
payment_source: create(:address),
user: create(:user)
}

error_message = { payment_source:["has to be a Spree::PaymentSource"] }
error_message = { payment_source: ["has to be a Spree::PaymentSource"] }
wallet_payment_source = subject.new(invalid_payment_source_attrs)

expect(wallet_payment_source).not_to be_valid
Expand All @@ -33,6 +32,5 @@
}
expect(subject.new(valid_attrs)).to be_valid
end

end
end
2 changes: 1 addition & 1 deletion frontend/app/controllers/spree/checkout_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def before_payment
if try_spree_current_user && try_spree_current_user.respond_to?(:wallet)
@wallet_payment_sources = try_spree_current_user.wallet.wallet_payment_sources
@default_wallet_payment_source = @wallet_payment_sources.detect(&:default) ||
@wallet_payment_sources.first
@wallet_payment_sources.first
# TODO: How can we deprecate this instance variable? We could try
# wrapping it in a delegating object that produces deprecation warnings.
@payment_sources = try_spree_current_user.wallet.wallet_payment_sources.map(&:payment_source).select { |wps| wps.is_a?(Spree::CreditCard) }
Expand Down

0 comments on commit 3e4cbf2

Please sign in to comment.