Skip to content
This repository was archived by the owner on Apr 14, 2023. It is now read-only.

Couple of minor improvements #62

Merged
merged 3 commits into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if branch == "master" || branch >= "v2.0"
gem "rails-controller-testing", group: :test
else
gem "rails", "~> 4.2"
gem "rails_test_params_backport", group: :test
end

# Provides basic authentication functionality for testing parts of your engine
Expand Down
8 changes: 7 additions & 1 deletion app/models/solidus_paypal_braintree/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module SolidusPaypalBraintree
class Source < ApplicationRecord
PAYPAL = "PayPalAccount"
APPLE_PAY = "ApplePayCard"
CREDIT_CARD = "CreditCard"

belongs_to :user, class_name: "Spree::User"
belongs_to :payment_method, class_name: 'Spree::PaymentMethod'
Expand All @@ -10,8 +11,9 @@ class Source < ApplicationRecord
belongs_to :customer, class_name: "SolidusPaypalBraintree::Customer"

scope :with_payment_profile, -> { joins(:customer) }
scope :credit_card, -> { where(payment_type: CREDIT_CARD) }

delegate :last_4, :card_type, to: :braintree_payment_method
delegate :last_4, :card_type, to: :braintree_payment_method, allow_nil: true

# we are not currenctly supporting an "imported" flag
def imported
Expand Down Expand Up @@ -46,6 +48,10 @@ def paypal?
payment_type == PAYPAL
end

def credit_card?
payment_type == CREDIT_CARD
end

private

def braintree_payment_method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
include_context 'order ready for payment'

describe 'PATCH update', vcr: { cassette_name: 'checkout/update' } do
subject(:patch_update) { patch :update, params }
subject(:patch_update) { patch :update, params: params }

let(:params) do
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

context 'with a payment method id' do
subject(:response) do
post :create, token: user.spree_api_key
post :create, params: { token: user.spree_api_key }
end

it "returns a client token", aggregate_failures: true do
Expand All @@ -30,7 +30,7 @@
end

subject(:response) do
post :create, token: user.spree_api_key, payment_method_id: 3
post :create, params: { token: user.spree_api_key, payment_method_id: 3 }
end

it 'uses the selected gateway' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
end

subject { post :update, configurations_params }
subject { post :update, params: configurations_params }

context "with valid parameters" do
it "updates the configuration" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

cassette_options = { cassette_name: "transactions_controller/create" }
describe "POST create", vcr: cassette_options do
subject(:post_create) { post :create, params }
subject(:post_create) { post :create, params: params }
let!(:country) { create :country, iso: 'US' }
let!(:state) { create :state, abbr: 'WA', country: country }

Expand Down