From 42dd58426e0421d6817be2fe3364911df5fc2c42 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 7 Jul 2017 15:03:22 +1000 Subject: [PATCH] Auto-correct rubocop offences for stripe-connect --- .../admin/stripe_accounts_controller.rb | 2 +- .../stripe_connect_settings_controller.rb | 14 +++++----- .../spree/admin/base_controller_decorator.rb | 2 +- .../spree/credit_cards_controller.rb | 25 +++++++++-------- app/models/spree/gateway/stripe_connect.rb | 20 +++++++------- app/models/spree/payment_decorator.rb | 6 ++--- app/models/stripe_account.rb | 4 +-- .../api/admin/payment_method_serializer.rb | 4 +-- .../admin/stripe_accounts_controller_spec.rb | 27 ++++++++++--------- ...stripe_connect_settings_controller_spec.rb | 6 ++--- .../spree/credit_cards_controller_spec.rb | 4 +-- .../spree/users_controller_spec.rb | 4 +-- spec/factories.rb | 1 - spec/features/admin/payment_method_spec.rb | 2 +- spec/features/admin/stripe_connect_spec.rb | 1 - spec/features/consumer/account/cards_spec.rb | 6 ++--- .../consumer/shopping/checkout_spec.rb | 2 +- spec/helpers/enterprises_helper_spec.rb | 4 +-- spec/lib/stripe/account_connector_spec.rb | 6 ++--- spec/lib/stripe/oauth_spec.rb | 2 +- .../spree/gateway/stripe_connect_spec.rb | 6 ++--- spec/models/stripe_account_spec.rb | 12 ++++----- spec/requests/stripe_connect_checkout_spec.rb | 4 +-- .../credit_card_serializer_spec.rb | 1 - 24 files changed, 78 insertions(+), 87 deletions(-) diff --git a/app/controllers/admin/stripe_accounts_controller.rb b/app/controllers/admin/stripe_accounts_controller.rb index e5325e917a..004ad7e664 100644 --- a/app/controllers/admin/stripe_accounts_controller.rb +++ b/app/controllers/admin/stripe_accounts_controller.rb @@ -39,7 +39,7 @@ module Admin begin status = Stripe::Account.retrieve(stripe_account.stripe_user_id) - attrs = [:id, :business_name, :charges_enabled] + attrs = %i[id business_name charges_enabled] render json: status.to_hash.slice(*attrs).merge( status: :connected) rescue Stripe::APIError => e render json: { status: :access_revoked } diff --git a/app/controllers/admin/stripe_connect_settings_controller.rb b/app/controllers/admin/stripe_connect_settings_controller.rb index 4e81f89e3c..a121609a1f 100644 --- a/app/controllers/admin/stripe_connect_settings_controller.rb +++ b/app/controllers/admin/stripe_connect_settings_controller.rb @@ -3,14 +3,12 @@ module Admin before_filter :load_settings, only: [:edit] def edit - begin - return @stripe_account = { status: :empty_api_key } if Stripe.api_key.blank? - attrs = [:id, :business_name, :charges_enabled] - @obfuscated_secret_key = obfuscated_secret_key - @stripe_account = Stripe::Account.retrieve.to_hash.slice(*attrs).merge(status: :ok) - rescue Stripe::AuthenticationError => e - @stripe_account = { status: :auth_fail } - end + return @stripe_account = { status: :empty_api_key } if Stripe.api_key.blank? + attrs = %i[id business_name charges_enabled] + @obfuscated_secret_key = obfuscated_secret_key + @stripe_account = Stripe::Account.retrieve.to_hash.slice(*attrs).merge(status: :ok) + rescue Stripe::AuthenticationError => e + @stripe_account = { status: :auth_fail } end def update diff --git a/app/controllers/spree/admin/base_controller_decorator.rb b/app/controllers/spree/admin/base_controller_decorator.rb index 58102e20eb..716f4ef50f 100644 --- a/app/controllers/spree/admin/base_controller_decorator.rb +++ b/app/controllers/spree/admin/base_controller_decorator.rb @@ -37,7 +37,7 @@ Spree::Admin::BaseController.class_eval do redirect_to '/unauthorized' else store_location - redirect_to root_path(anchor: "login?after_login=#{ request.env['PATH_INFO'] }") + redirect_to root_path(anchor: "login?after_login=#{request.env['PATH_INFO']}") end end diff --git a/app/controllers/spree/credit_cards_controller.rb b/app/controllers/spree/credit_cards_controller.rb index 53fb641f5c..90f754a3fe 100644 --- a/app/controllers/spree/credit_cards_controller.rb +++ b/app/controllers/spree/credit_cards_controller.rb @@ -1,24 +1,22 @@ module Spree class CreditCardsController < BaseController - before_filter :set_credit_card, only: [:destroy] before_filter :destroy_at_stripe, only: [:destroy] def new_from_token # A new Customer is created for every credit card (same as via ActiveMerchant) # Note that default_source is the card represented by the token - begin - @customer = create_customer(params[:token]) - @credit_card = build_card_from(stored_card_attributes) - if @credit_card.save - render json: @credit_card, serializer: ::Api::CreditCardSerializer, status: :ok - else - message = t(:card_could_not_be_saved) - render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: message) } }, status: 400 - end - rescue Stripe::CardError => e - return render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: e.message) } }, status: 400 + + @customer = create_customer(params[:token]) + @credit_card = build_card_from(stored_card_attributes) + if @credit_card.save + render json: @credit_card, serializer: ::Api::CreditCardSerializer, status: :ok + else + message = t(:card_could_not_be_saved) + render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: message) } }, status: 400 end + rescue Stripe::CardError => e + return render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: e.message) } }, status: 400 end def destroy @@ -35,7 +33,8 @@ module Spree end end - private + private + def create_customer(token) Stripe::Customer.create(email: spree_current_user.email, source: token) end diff --git a/app/models/spree/gateway/stripe_connect.rb b/app/models/spree/gateway/stripe_connect.rb index eec28fddd8..0927730e26 100644 --- a/app/models/spree/gateway/stripe_connect.rb +++ b/app/models/spree/gateway/stripe_connect.rb @@ -8,7 +8,7 @@ module Spree 'American Express' => 'american_express', 'Diners Club' => 'diners_club', 'Visa' => 'visa' - } + }.freeze def method_type 'stripe' @@ -61,11 +61,9 @@ module Spree response = provider.store(creditcard, options) if response.success? - payment.source.update_attributes!({ - cc_type: payment.source.cc_type, # side-effect of update_source! - gateway_customer_profile_id: response.params['id'], - gateway_payment_profile_id: response.params['default_source'] || response.params['default_card'] - }) + payment.source.update_attributes!( cc_type: payment.source.cc_type, # side-effect of update_source! + gateway_customer_profile_id: response.params['id'], + gateway_payment_profile_id: response.params['default_source'] || response.params['default_card']) else payment.send(:gateway_error, response.message) end @@ -87,21 +85,21 @@ module Spree creditcard = token_from_card_profile_ids(creditcard) - return money, creditcard, options + [money, creditcard, options] end def address_for(payment) {}.tap do |options| if address = payment.order.bill_address - options.merge!(address: { + options[:address] = { address1: address.address1, address2: address.address2, city: address.city, zip: address.zipcode - }) + } if country = address.country - options[:address].merge!(country: country.name) + options[:address][:country] = country.name end if state = address.state @@ -142,7 +140,7 @@ module Spree end def tokenize_instance_customer_card(customer, card) - token = Stripe::Token.create({card: card, customer: customer}, {stripe_account: stripe_account_id}) + token = Stripe::Token.create({card: card, customer: customer}, stripe_account: stripe_account_id) token.id rescue Stripe::StripeError => e Rails.logger.error("Stripe Error: #{e}") diff --git a/app/models/spree/payment_decorator.rb b/app/models/spree/payment_decorator.rb index bede38dbe7..a13f71e041 100644 --- a/app/models/spree/payment_decorator.rb +++ b/app/models/spree/payment_decorator.rb @@ -78,10 +78,10 @@ module Spree # Import from future Spree def build_source return if source_attributes.nil? - if payment_method and payment_method.payment_source_class + if payment_method && payment_method.payment_source_class self.source = payment_method.payment_source_class.new(source_attributes) - self.source.payment_method_id = payment_method.id - self.source.user_id = self.order.user_id if self.order + source.payment_method_id = payment_method.id + source.user_id = order.user_id if order end end diff --git a/app/models/stripe_account.rb b/app/models/stripe_account.rb index 8c727533f0..6aac4b4dfd 100644 --- a/app/models/stripe_account.rb +++ b/app/models/stripe_account.rb @@ -1,7 +1,7 @@ class StripeAccount < ActiveRecord::Base belongs_to :enterprise - validates_presence_of :stripe_user_id, :stripe_publishable_key - validates_uniqueness_of :enterprise_id + validates :stripe_user_id, :stripe_publishable_key, presence: true + validates :enterprise_id, uniqueness: true def deauthorize_and_destroy accounts = StripeAccount.where(stripe_user_id: stripe_user_id) diff --git a/app/serializers/api/admin/payment_method_serializer.rb b/app/serializers/api/admin/payment_method_serializer.rb index edcf482915..8b2c4e1cf0 100644 --- a/app/serializers/api/admin/payment_method_serializer.rb +++ b/app/serializers/api/admin/payment_method_serializer.rb @@ -1,7 +1,5 @@ class Api::Admin::PaymentMethodSerializer < ActiveModel::Serializer - def serializable_hash - method_serializer.serializable_hash - end + delegate :serializable_hash, to: :method_serializer def method_serializer if object.type == 'Spree::Gateway::StripeConnect' diff --git a/spec/controllers/admin/stripe_accounts_controller_spec.rb b/spec/controllers/admin/stripe_accounts_controller_spec.rb index 047885041f..01dff11d31 100644 --- a/spec/controllers/admin/stripe_accounts_controller_spec.rb +++ b/spec/controllers/admin/stripe_accounts_controller_spec.rb @@ -1,12 +1,11 @@ require 'spec_helper' describe Admin::StripeAccountsController, type: :controller do - describe "destroy_from_webhook" do let!(:stripe_account) { create(:stripe_account, stripe_user_id: "webhook_id") } let(:params) do { - "format"=> "json", + "format" => "json", "id" => "evt_123", "object" => "event", "data" => { "object" => { "id" => "ca_9B" } }, @@ -49,7 +48,7 @@ describe Admin::StripeAccountsController, type: :controller do describe "destroy" do let(:enterprise) { create(:distributor_enterprise) } - let(:params) { { format: :json, id: "some_id" } } + let(:params) { { format: :json, id: "some_id" } } context "when the specified stripe account doesn't exist" do it "raises an error?" do @@ -109,7 +108,7 @@ describe Admin::StripeAccountsController, type: :controller do before do Stripe.api_key = "sk_test_12345" - Spree::Config.set({stripe_connect_enabled: false}) + Spree::Config.set(stripe_connect_enabled: false) end context "where I don't manage the specified enterprise" do @@ -117,7 +116,7 @@ describe Admin::StripeAccountsController, type: :controller do let(:enterprise2) { create(:enterprise) } before do user.owned_enterprises << enterprise2 - params.merge!({enterprise_id: enterprise.id}) + params[:enterprise_id] = enterprise.id allow(controller).to receive(:spree_current_user) { user } end @@ -129,7 +128,7 @@ describe Admin::StripeAccountsController, type: :controller do context "where I manage the specified enterprise" do before do - params.merge!({enterprise_id: enterprise.id}) + params[:enterprise_id] = enterprise.id allow(controller).to receive(:spree_current_user) { enterprise.owner } end @@ -142,7 +141,7 @@ describe Admin::StripeAccountsController, type: :controller do end context "and Stripe is enabled" do - before { Spree::Config.set({stripe_connect_enabled: true}) } + before { Spree::Config.set(stripe_connect_enabled: true) } context "but it has no associated stripe account" do it "returns with a status of 'account_missing'" do @@ -168,12 +167,14 @@ describe Admin::StripeAccountsController, type: :controller do end context "which is connected" do - let(:stripe_account_mock) { { - id: "acc_123", - business_name: "My Org", - charges_enabled: true, - some_other_attr: "something" - } } + let(:stripe_account_mock) do + { + id: "acc_123", + business_name: "My Org", + charges_enabled: true, + some_other_attr: "something" + } + end before do stub_request(:get, "https://api.stripe.com/v1/accounts/acc_123").to_return(body: JSON.generate(stripe_account_mock)) diff --git a/spec/controllers/admin/stripe_connect_settings_controller_spec.rb b/spec/controllers/admin/stripe_connect_settings_controller_spec.rb index 6a029d2bf7..2614f2065f 100644 --- a/spec/controllers/admin/stripe_connect_settings_controller_spec.rb +++ b/spec/controllers/admin/stripe_connect_settings_controller_spec.rb @@ -37,7 +37,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do context "and the request to retrieve Stripe account info fails" do before do stub_request(:get, "https://api.stripe.com/v1/account"). - to_return(:status => 401, :body => "{\"error\": {\"message\": \"Invalid API Key provided: sk_test_****xxxx\"}}") + to_return(:status => 401, :body => "{\"error\": {\"message\": \"Invalid API Key provided: sk_test_****xxxx\"}}") end it "sets the account status to :auth_fail" do @@ -50,7 +50,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do context "and the request to retrieve Stripe account info succeeds" do before do stub_request(:get, "https://api.stripe.com/v1/account"). - to_return(:status => 200, :body => "{ \"id\": \"acct_1234\", \"business_name\": \"OFN\" }") + to_return(:status => 200, :body => "{ \"id\": \"acct_1234\", \"business_name\": \"OFN\" }") end it "sets the account status to :ok, loads settings into Struct" do @@ -77,7 +77,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do end context "as super admin" do - before {allow(controller).to receive(:spree_current_user) { admin } } + before { allow(controller).to receive(:spree_current_user) { admin } } it "sets global config to the specified values" do expect(Spree::Config.stripe_connect_enabled).to be true diff --git a/spec/controllers/spree/credit_cards_controller_spec.rb b/spec/controllers/spree/credit_cards_controller_spec.rb index 4c183cb9d1..e1e5b5fec7 100644 --- a/spec/controllers/spree/credit_cards_controller_spec.rb +++ b/spec/controllers/spree/credit_cards_controller_spec.rb @@ -26,7 +26,7 @@ describe Spree::CreditCardsController do describe "#new_from_token" do context "when the request to store the customer/card with Stripe is successful" do - let(:response_mock) { { status: 200, body: JSON.generate({ id: "cus_AZNMJ", default_source: "card_1AEEb" }) } } + let(:response_mock) { { status: 200, body: JSON.generate(id: "cus_AZNMJ", default_source: "card_1AEEb") } } it "saves the card locally" do expect{ post :new_from_token, params }.to change(Spree::CreditCard, :count).by(1) @@ -54,7 +54,7 @@ describe Spree::CreditCardsController do end context "when the request to store the customer/card with Stripe fails" do - let(:response_mock) { { status: 402, body: JSON.generate({ error: { message: "Bup-bow..." }}) } } + let(:response_mock) { { status: 402, body: JSON.generate(error: { message: "Bup-bow..." }) } } it "doesn't save the card locally, and renders a flash error" do expect{ post :new_from_token, params }.to_not change(Spree::CreditCard, :count) diff --git a/spec/controllers/spree/users_controller_spec.rb b/spec/controllers/spree/users_controller_spec.rb index cbb08ece20..f980e21498 100644 --- a/spec/controllers/spree/users_controller_spec.rb +++ b/spec/controllers/spree/users_controller_spec.rb @@ -13,14 +13,14 @@ describe Spree::UsersController do let!(:d1_order_for_u2) { create(:completed_order_with_totals, distributor: distributor1, user_id: u2.id) } let!(:d1o3) { create(:order, state: 'cart', distributor: distributor1, user_id: u1.id) } let!(:d2o1) { create(:completed_order_with_totals, distributor: distributor2, user_id: u2.id) } - let!(:accounts_distributor) {create :distributor_enterprise} + let!(:accounts_distributor) { create :distributor_enterprise } let!(:order_account_invoice) { create(:order, distributor: accounts_distributor, state: 'complete', user: u1) } let(:orders) { assigns(:orders) } let(:shops) { Enterprise.where(id: orders.pluck(:distributor_id)) } before do - Spree::Config.set({ accounts_distributor_id: accounts_distributor.id }) + Spree::Config.set(accounts_distributor_id: accounts_distributor.id) allow(controller).to receive(:spree_current_user) { u1 } end diff --git a/spec/factories.rb b/spec/factories.rb index a574d88edf..6592dc2940 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -368,7 +368,6 @@ FactoryGirl.define do stripe_user_id "abc123" stripe_publishable_key "xyz456" end - end diff --git a/spec/features/admin/payment_method_spec.rb b/spec/features/admin/payment_method_spec.rb index 6a82e7951b..ac3b9df118 100644 --- a/spec/features/admin/payment_method_spec.rb +++ b/spec/features/admin/payment_method_spec.rb @@ -40,7 +40,7 @@ feature %q{ let!(:stripe_account_mock) { { id: "acc_connected123", business_name: "My Org", charges_enabled: true } } before do - Spree::Config.set({stripe_connect_enabled: true}) + Spree::Config.set(stripe_connect_enabled: true) Stripe.api_key = "sk_test_12345" stub_request(:get, "https://api.stripe.com/v1/accounts/acc_connected123").to_return(body: JSON.generate(stripe_account_mock)) stub_request(:get, "https://api.stripe.com/v1/accounts/acc_revoked123").to_return(status: 404) diff --git a/spec/features/admin/stripe_connect_spec.rb b/spec/features/admin/stripe_connect_spec.rb index f68280c710..1c56f703e9 100644 --- a/spec/features/admin/stripe_connect_spec.rb +++ b/spec/features/admin/stripe_connect_spec.rb @@ -8,5 +8,4 @@ feature "Connecting a Stripe Account" do before(:each) do login_to_admin_as enterprise_user end - end diff --git a/spec/features/consumer/account/cards_spec.rb b/spec/features/consumer/account/cards_spec.rb index ed12543099..86b1092ccc 100644 --- a/spec/features/consumer/account/cards_spec.rb +++ b/spec/features/consumer/account/cards_spec.rb @@ -10,13 +10,13 @@ feature "Credit Cards", js: true do quick_login_as user Stripe.api_key = "sk_test_xxxx" - Spree::Config.set({stripe_connect_enabled: true}) + Spree::Config.set(stripe_connect_enabled: true) stub_request(:get, "https://api.stripe.com/v1/customers/cus_AZNMJ"). - to_return(:status => 200, :body => JSON.generate({id: "cus_AZNMJ"})) + to_return(:status => 200, :body => JSON.generate(id: "cus_AZNMJ")) stub_request(:delete, "https://api.stripe.com/v1/customers/cus_AZNMJ"). - to_return(:status => 200, :body => JSON.generate({deleted: true, id: "cus_AZNMJ"})) + to_return(:status => 200, :body => JSON.generate(deleted: true, id: "cus_AZNMJ")) end it "lists saved cards, shows interface for adding new cards" do diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 6dbe5dc445..508a9ba9d7 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -157,7 +157,7 @@ feature "As a consumer I want to check out my cart", js: true, retry: 3 do before do Stripe.api_key = "sk_test_123456" - Spree::Config.set({stripe_connect_enabled: true}) + Spree::Config.set(stripe_connect_enabled: true) stub_request(:post, "https://sk_test_123456:@api.stripe.com/v1/charges") .to_return(body: JSON.generate(response_mock)) diff --git a/spec/helpers/enterprises_helper_spec.rb b/spec/helpers/enterprises_helper_spec.rb index ebfaa8d890..2aa9131942 100644 --- a/spec/helpers/enterprises_helper_spec.rb +++ b/spec/helpers/enterprises_helper_spec.rb @@ -225,7 +225,7 @@ describe EnterprisesHelper do before { allow(helper).to receive(:current_distributor) { distributor } } context "and Stripe Connect is disabled" do - before { Spree::Config.set({stripe_connect_enabled: false}) } + before { Spree::Config.set(stripe_connect_enabled: false) } it "ignores the Stripe payment method" do expect(helper.available_payment_methods.map(&:id)).to_not include pm3.id @@ -233,7 +233,7 @@ describe EnterprisesHelper do end context "and Stripe Connect is enabled" do - before { Spree::Config.set({stripe_connect_enabled: true}) } + before { Spree::Config.set(stripe_connect_enabled: true) } it "includes the Stripe payment method" do expect(helper.available_payment_methods.map(&:id)).to include pm3.id diff --git a/spec/lib/stripe/account_connector_spec.rb b/spec/lib/stripe/account_connector_spec.rb index 51893bf806..119d6c7e38 100644 --- a/spec/lib/stripe/account_connector_spec.rb +++ b/spec/lib/stripe/account_connector_spec.rb @@ -13,7 +13,7 @@ module Stripe context "when params have no 'code' key" do it "raises a StripeError" do - expect{ AccountConnector.new(user, params) }.to raise_error StripeError + expect{ AccountConnector.new(user, params) }.to raise_error StripeError end end @@ -53,7 +53,7 @@ module Stripe it "allows creations of a new Stripe Account from the callback params" do connector = AccountConnector.new(user, params) - expect{connector.create_account}.to change(StripeAccount, :count).by(1) + expect{ connector.create_account }.to change(StripeAccount, :count).by(1) end end @@ -67,7 +67,7 @@ module Stripe it "allows creations of a new Stripe Account from the callback params" do connector = AccountConnector.new(user, params) - expect{connector.create_account}.to change(StripeAccount, :count).by(1) + expect{ connector.create_account }.to change(StripeAccount, :count).by(1) end end end diff --git a/spec/lib/stripe/oauth_spec.rb b/spec/lib/stripe/oauth_spec.rb index 6f46f138cb..c7b16ca257 100644 --- a/spec/lib/stripe/oauth_spec.rb +++ b/spec/lib/stripe/oauth_spec.rb @@ -13,7 +13,7 @@ module Stripe it "builds a url with all of the necessary params" do url = OAuth.authorize_url(enterprise_id) uri = URI.parse(url) - params = CGI::parse(uri.query) + params = CGI.parse(uri.query) expect(params.keys).to include 'client_id', 'response_type', 'state', 'scope' expect(params["state"]).to eq [OAuth.jwt_encode(enterprise_id: enterprise_id)] expect(uri.scheme).to eq 'https' diff --git a/spec/models/spree/gateway/stripe_connect_spec.rb b/spec/models/spree/gateway/stripe_connect_spec.rb index d2cc2310ea..377cb0c968 100644 --- a/spec/models/spree/gateway/stripe_connect_spec.rb +++ b/spec/models/spree/gateway/stripe_connect_spec.rb @@ -11,7 +11,7 @@ describe Spree::Gateway::StripeConnect, type: :model do before do Stripe.api_key = "sk_test_123456" - subject.stub(:options_for_purchase_or_auth).and_return(['money','cc','opts']) + subject.stub(:options_for_purchase_or_auth).and_return(['money', 'cc', 'opts']) subject.stub(:provider).and_return provider end @@ -59,8 +59,8 @@ describe Spree::Gateway::StripeConnect, type: :model do before do stub_request(:post, "https://api.stripe.com/v1/tokens") - .with(body: { "card"=>"card123", "customer"=>"customer123"}) - .to_return(body: JSON.generate(token_mock)) + .with(body: { "card" => "card123", "customer" => "customer123"}) + .to_return(body: JSON.generate(token_mock)) end it "requests a new token for the customer and card from Stripe, and returns the id of the response" do diff --git a/spec/models/stripe_account_spec.rb b/spec/models/stripe_account_spec.rb index dd81c202b1..7244e44979 100644 --- a/spec/models/stripe_account_spec.rb +++ b/spec/models/stripe_account_spec.rb @@ -10,9 +10,9 @@ describe StripeAccount do context "when the Stripe API disconnect fails" do before do Stripe::OAuth.client - .deauthorize(stripe_account.stripe_user_id) - .stub(:deauthorize_request) - .and_return(nil) + .deauthorize(stripe_account.stripe_user_id) + .stub(:deauthorize_request) + .and_return(nil) end it "doesn't destroy the record" do @@ -24,9 +24,9 @@ describe StripeAccount do context "when the Stripe API disconnect succeeds" do before do Stripe::OAuth.client - .deauthorize(stripe_account.stripe_user_id) - .stub(:deauthorize_request) - .and_return("something truthy") + .deauthorize(stripe_account.stripe_user_id) + .stub(:deauthorize_request) + .and_return("something truthy") end it "destroys the record" do diff --git a/spec/requests/stripe_connect_checkout_spec.rb b/spec/requests/stripe_connect_checkout_spec.rb index 7cd63fb0b5..6e5d10517f 100644 --- a/spec/requests/stripe_connect_checkout_spec.rb +++ b/spec/requests/stripe_connect_checkout_spec.rb @@ -21,8 +21,8 @@ describe "Submitting Stripe Connect charge requests", type: :request do { format: :json, order: { shipping_method_id: shipping_method.id, payments_attributes: [{payment_method_id: payment_method.id, source_attributes: { gateway_payment_profile_id: token, cc_type: "visa", last_digits: "4242", month: 10, year: 2025 }}], - bill_address_attributes: address.attributes.slice("firstname","lastname","address1","address2","phone","city","zipcode","state_id","country_id"), - ship_address_attributes: address.attributes.slice("firstname","lastname","address1","address2","phone","city","zipcode","state_id","country_id") + bill_address_attributes: address.attributes.slice("firstname", "lastname", "address1", "address2", "phone", "city", "zipcode", "state_id", "country_id"), + ship_address_attributes: address.attributes.slice("firstname", "lastname", "address1", "address2", "phone", "city", "zipcode", "state_id", "country_id") } } end diff --git a/spec/serializers/credit_card_serializer_spec.rb b/spec/serializers/credit_card_serializer_spec.rb index 100067b2e5..baa9c2a3e9 100644 --- a/spec/serializers/credit_card_serializer_spec.rb +++ b/spec/serializers/credit_card_serializer_spec.rb @@ -12,5 +12,4 @@ describe Api::CreditCardSerializer do it "formats an identifying string with the card number masked" do expect(serializer.formatted).to eq "Visa x-1111 Exp:12/2013" end - end