rubocop correct

This commit is contained in:
Rimian Perkins 2019-08-27 20:04:02 +10:00
parent f49c0c89a3
commit 6f826ce7a0
25 changed files with 47 additions and 7 deletions

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
load File.expand_path('../discourse_donations/charges_controller.rb', __FILE__)
load File.expand_path('../discourse_donations/checkout_controller.rb', __FILE__)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DiscourseDonations
class ChargesController < ::ApplicationController
skip_before_action :verify_authenticity_token, only: [:create]

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require_dependency 'discourse'
module DiscourseDonations

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
load File.expand_path('../regular/donation_user.rb', __FILE__)
load File.expand_path('../scheduled/update_category_donation_statistics.rb', __FILE__)

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Jobs
class DonationUser < ::Jobs::Base

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Jobs
class UpdateCategoryDonationStatistics < ::Jobs::Scheduled
every 1.day

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module DiscourseDonations
class Rewards

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module DiscourseDonations
class Stripe
attr_reader :charge, :currency, :description

View File

@ -1,2 +1,4 @@
# frozen_string_literal: true
load File.expand_path('../discourse_donations/rewards.rb', __FILE__)
load File.expand_path('../discourse_donations/stripe.rb', __FILE__)

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
DiscourseDonations::Engine.routes.draw do
get '/' => 'charges#index'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ::DiscourseDonations
class Engine < ::Rails::Engine
engine_name 'discourse-donations'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
# name: discourse-donations
# about: Integrates Stripe into Discourse to allow forum visitors to make donations
# version: 1.11.3

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper'
shared_examples 'failure response' do |message_key|

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Fabricator(:stripe_charge, from: "DiscourseDonations::StripeResponse") do
response = {

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Fabricator(:stripe_customer, from: "DiscourseDonations::StripeResponse") do
response = {

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Fabricator(:stripe_invoices, from: "DiscourseDonations::StripeResponse") do
response = {

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Fabricator(:stripe_plans, from: "DiscourseDonations::StripeResponse") do
response = {

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Fabricator(:stripe_products, from: "DiscourseDonations::StripeResponse") do
response = {

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# This is for building http responses with Fabricate
# Usage: Fabricate(:customer).to_json

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Fabricator(:stripe_subscription, from: "DiscourseDonations::StripeResponse") do
response = {

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Jobs::DonationUser, type: :job do

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative './fabricators/charge_fabricator.rb'
require_relative './fabricators/customer_fabricator.rb'

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper'
module DiscourseDonations

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'rails_helper'
require_relative '../../support/dd_helper'
@ -61,7 +63,7 @@ module DiscourseDonations
description: stripe_options[:description],
currency: stripe_options[:currency],
receipt_email: customer.email,
:metadata => { :discourse_cause => nil }
metadata: { discourse_cause: nil }
}
end
@ -72,7 +74,7 @@ module DiscourseDonations
it 'is successful' do
::Stripe::Charge.expects(:create).with(charge_options).returns(paid: true)
::Stripe::Customer.expects(:list).returns({ data: [] })
::Stripe::Customer.expects(:list).returns(data: [])
subject.charge(nil, params)
expect(subject).to be_successful
@ -80,7 +82,7 @@ module DiscourseDonations
it 'is not successful' do
::Stripe::Charge.expects(:create).with(charge_options).returns(paid: false)
::Stripe::Customer.expects(:list).returns({ data: [] })
::Stripe::Customer.expects(:list).returns(data: [])
subject.charge(nil, params)
expect(subject).not_to be_successful
end

View File

@ -1,9 +1,11 @@
# frozen_string_literal: true
require 'fakeweb'
#TODO register some fixtures
FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/customers',
:body => '{
body: '{
"id": "cus_AJqrL4OU1sffPl",
"object": "customer",
"account_balance": 0,
@ -52,11 +54,11 @@ FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/customers',
"url": "/v1/customers/cus_AJqrL4OU1sffPl/sources"
}
}',
:status => ['200', 'OK']
status: ['200', 'OK']
)
FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/charges',
:body => '{
body: '{
"id": "ch_19zDAFEfVxQsvRbHtAwsCvV0",
"object": "charge",
"amount": 100,
@ -133,5 +135,5 @@ FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/charges',
"status": "succeeded",
"transfer_group": null
}',
:status => ['200', 'OK']
status: ['200', 'OK']
)