rubocop correct
This commit is contained in:
parent
f49c0c89a3
commit
6f826ce7a0
|
@ -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__)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiscourseDonations
|
||||
class ChargesController < ::ApplicationController
|
||||
skip_before_action :verify_authenticity_token, only: [:create]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_dependency 'discourse'
|
||||
|
||||
module DiscourseDonations
|
||||
|
|
|
@ -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__)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class DonationUser < ::Jobs::Base
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Jobs
|
||||
class UpdateCategoryDonationStatistics < ::Jobs::Scheduled
|
||||
every 1.day
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiscourseDonations
|
||||
class Rewards
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiscourseDonations
|
||||
class Stripe
|
||||
attr_reader :charge, :currency, :description
|
||||
|
|
|
@ -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__)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
DiscourseDonations::Engine.routes.draw do
|
||||
get '/' => 'charges#index'
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ::DiscourseDonations
|
||||
class Engine < ::Rails::Engine
|
||||
engine_name 'discourse-donations'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
shared_examples 'failure response' do |message_key|
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:stripe_charge, from: "DiscourseDonations::StripeResponse") do
|
||||
response = {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:stripe_customer, from: "DiscourseDonations::StripeResponse") do
|
||||
response = {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:stripe_invoices, from: "DiscourseDonations::StripeResponse") do
|
||||
response = {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:stripe_plans, from: "DiscourseDonations::StripeResponse") do
|
||||
response = {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:stripe_products, from: "DiscourseDonations::StripeResponse") do
|
||||
response = {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This is for building http responses with Fabricate
|
||||
# Usage: Fabricate(:customer).to_json
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:stripe_subscription, from: "DiscourseDonations::StripeResponse") do
|
||||
response = {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Jobs::DonationUser, type: :job do
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative './fabricators/charge_fabricator.rb'
|
||||
require_relative './fabricators/customer_fabricator.rb'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
module DiscourseDonations
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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']
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue