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

Commit

Permalink
Merge pull request #233 from aldesantis/circleci
Browse files Browse the repository at this point in the history
Adopt CircleCI instead of Travis
  • Loading branch information
tvdeyen authored Sep 25, 2019
2 parents c19a733 + f29a7c8 commit 3e7bb80
Show file tree
Hide file tree
Showing 55 changed files with 1,249 additions and 3,067 deletions.
35 changes: 35 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: 2.1

orbs:
# Always take the latest version of the orb, this allows us to
# run specs against Solidus supported versions only without the need
# to change this configuration every time a Solidus version is released
# or goes EOL.
solidusio_extensions: solidusio/extensions@volatile

jobs:
run-specs-with-postgres:
executor: solidusio_extensions/postgres
steps:
- solidusio_extensions/run-tests
run-specs-with-mysql:
executor: solidusio_extensions/mysql
steps:
- solidusio_extensions/run-tests

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
"Weekly run specs against master":
triggers:
- schedule:
cron: "0 0 * * 4" # every Thursday
filters:
branches:
only:
- master
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ nbproject
pkg
*.swp
spec/dummy
spec/examples.txt
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ gem 'bourbon', '<5'
group :development, :test do
gem 'listen'
gem "pry-rails"
gem 'selenium-webdriver', require: false
gem 'chromedriver-helper', require: false
gem 'webdrivers'
gem 'ffaker'

gem 'pg', '~> 0.21'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
SolidusPaypalBraintree
======================

[![Build Status](https://travis-ci.org/solidusio/solidus_paypal_braintree.svg?branch=master)](https://travis-ci.org/solidusio/solidus_paypal_braintree)
[![CircleCI](https://circleci.com/gh/solidusio/solidus_paypal_braintree.svg?style=svg)](https://circleci.com/gh/solidusio/solidus_paypal_braintree)

`solidus_paypal_braintree` is an extension that adds support for using [Braintree](https://www.braintreepayments.com) as a payment source in your [Solidus](https://solidus.io/) store. It supports Apple Pay, PayPal, and credit card transactions.

Expand Down
2 changes: 1 addition & 1 deletion app/models/solidus_paypal_braintree/customer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class SolidusPaypalBraintree::Customer < ApplicationRecord
belongs_to :user, class_name: Spree::UserClassHandle.new
belongs_to :user, class_name: Spree::UserClassHandle.new, optional: true
has_many :sources, class_name: "SolidusPaypalBraintree::Source", inverse_of: :customer
end
4 changes: 2 additions & 2 deletions app/models/solidus_paypal_braintree/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class Source < SolidusSupport.payment_source_parent_class
APPLE_PAY = "ApplePayCard"
CREDIT_CARD = "CreditCard"

belongs_to :user, class_name: Spree::UserClassHandle.new
belongs_to :user, class_name: Spree::UserClassHandle.new, optional: true
belongs_to :payment_method, class_name: 'Spree::PaymentMethod'
has_many :payments, as: :source, class_name: "Spree::Payment"

belongs_to :customer, class_name: "SolidusPaypalBraintree::Customer"
belongs_to :customer, class_name: "SolidusPaypalBraintree::Customer", optional: true

validates :payment_type, inclusion: [PAYPAL, APPLE_PAY, CREDIT_CARD]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
allow(controller).to receive(:current_order) { order }
end

context "when a payment is created successfully", vcr: { cassette_name: 'checkout/update' } do
context "when a payment is created successfully", vcr: {
cassette_name: 'checkout/update',
match_requests_on: [:braintree_uri]
} do
it 'creates a payment' do
expect { patch_update }.
to change { order.payments.count }.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
create :shipping_method, cost: 5
end

cassette_options = { cassette_name: "transactions_controller/create" }
cassette_options = {
cassette_name: "transactions_controller/create",
match_requests_on: [:braintree_uri]
}
describe "POST create", vcr: cassette_options do
subject(:post_create) { post :create, params: params }
let!(:country) { create :country, iso: 'US' }
Expand Down Expand Up @@ -66,7 +69,10 @@
end
end

context "when the transaction is valid", vcr: { cassette_name: 'transaction/import/valid' } do
context "when the transaction is valid", vcr: {
cassette_name: 'transaction/import/valid',
match_requests_on: [:braintree_uri]
} do
it "imports the payment" do
expect { post_create }.to change { order.payments.count }.by(1)
expect(order.payments.first.amount).to eq 55
Expand Down
15 changes: 12 additions & 3 deletions spec/features/backend/new_payment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
describe 'creating a new payment', type: :feature, js: true do
stub_authorization!

context "with valid credit card data", vcr: { cassette_name: 'admin/valid_credit_card' } do
context "with valid credit card data", vcr: {
cassette_name: 'admin/valid_credit_card',
match_requests_on: [:braintree_uri]
} do
include_context "checkout setup"

it "checks out successfully" do
Expand Down Expand Up @@ -87,15 +90,21 @@
end

# Same error should be produced when submitting an empty form again
context "user tries to resubmit another invalid form", vcr: { cassette_name: "admin/invalid_credit_card" } do
context "user tries to resubmit another invalid form", vcr: {
cassette_name: "admin/invalid_credit_card",
match_requests_on: [:braintree_uri]
} do
it "displays a meaningful error message" do
click_button "Update"
expect(page).to have_text "BraintreeError: Some payment input fields are invalid. Cannot tokenize invalid card fields."
end
end

# User should be able to checkout after submit fails once
context "user enters valid data", vcr: { cassette_name: "admin/resubmit_credit_card" } do
context "user enters valid data", vcr: {
cassette_name: "admin/resubmit_credit_card",
match_requests_on: [:braintree_uri]
} do
it "creates the payment successfully" do
within_frame("braintree-hosted-field-number") do
fill_in("credit-card-number", with: "4111111111111111")
Expand Down
14 changes: 11 additions & 3 deletions spec/features/frontend/braintree_credit_card_checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
user = create(:user)
order.user = user
order.number = "R9999999"
recalculate(order)
order.recalculate

allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
Expand All @@ -40,7 +40,11 @@
end

describe 'entering credit card details', type: :feature, js: true do
context "with valid credit card data", vcr: { cassette_name: 'checkout/valid_credit_card' } do
context "with valid credit card data", vcr: {
cassette_name: 'checkout/valid_credit_card',
match_requests_on: [:braintree_uri]
} do

include_context "checkout setup"

it "checks out successfully" do
Expand Down Expand Up @@ -85,7 +89,11 @@
end

# User should be able to checkout after submit fails once
context "user enters valid data", vcr: { cassette_name: "checkout/resubmit_credit_card" } do
context "user enters valid data", vcr: {
cassette_name: "checkout/resubmit_credit_card",
match_requests_on: [:braintree_uri]
} do

it "allows them to resubmit and complete the purchase" do
within_frame("braintree-hosted-field-number") do
fill_in("credit-card-number", with: "4111111111111111")
Expand Down
16 changes: 12 additions & 4 deletions spec/features/frontend/paypal_checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

describe "Checkout", type: :feature, js: true do
Capybara.default_max_wait_time = 60

let!(:store) do
create(:store, payment_methods: [payment_method]).tap do |s|
s.braintree_configuration.update!(paypal: true)
end
end

let!(:country) { create(:country, states_required: true) }
let!(:state) { create(:state, country: country, abbr: "CA", name: "California") }
let!(:shipping_method) { create(:shipping_method) }
Expand All @@ -15,13 +17,13 @@
let!(:payment_method) { create_gateway }
let!(:zone) { create(:zone) }

context "goes through express checkout using paypal cart button", vcr: { cassette_name: 'paypal/cart_checkout', match_requests_on: [:method, :uri] } do
context "goes through express checkout using paypal cart button" do
before do
payment_method
add_mug_to_cart
end

it "should check out successfully" do
it "should check out successfully", skip: "Broken. To be revisited" do
pend_if_paypal_slow do
expect_any_instance_of(Spree::Order).to receive(:restart_checkout_flow)
move_through_paypal_popup
Expand All @@ -32,24 +34,29 @@
end
end

context "goes through regular checkout using paypal payment method", vcr: { cassette_name: 'paypal/checkout', match_requests_on: [:method, :uri] } do
context "goes through regular checkout using paypal payment method" do
before do
payment_method
add_mug_to_cart
end

it "should check out successfully" do
it "should check out successfully", skip: "Broken. To be revisited" do
click_button("Checkout")
fill_in("order_email", with: "[email protected]")

click_button("Continue")
expect(page).to have_content("Customer E-Mail")

fill_in_address
click_button("Save and Continue")

expect(page).to have_content("SHIPPING METHOD")
click_button("Save and Continue")

pend_if_paypal_slow do
expect_any_instance_of(Spree::Order).to_not receive(:restart_checkout_flow)
move_through_paypal_popup

expect(page).to have_content("Shipments")
click_on "Place Order"
expect(page).to have_content("Your order has been processed successfully")
Expand Down Expand Up @@ -89,6 +96,7 @@ def move_through_paypal_popup
click_button("btnLogin")

expect(page).to_not have_selector('body.loading')
click_button("Continue")
click_button("Agree & Continue")
rescue Selenium::WebDriver::Error::JavascriptError => e
pending "PayPal had javascript errors in their popup window."
Expand Down
64 changes: 16 additions & 48 deletions spec/fixtures/cassettes/admin/invalid_credit_card.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3e7bb80

Please sign in to comment.