mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-08 15:22:46 +00:00
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/charges_controller.rb', __FILE__)
|
||||||
load File.expand_path('../discourse_donations/checkout_controller.rb', __FILE__)
|
load File.expand_path('../discourse_donations/checkout_controller.rb', __FILE__)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module DiscourseDonations
|
module DiscourseDonations
|
||||||
class ChargesController < ::ApplicationController
|
class ChargesController < ::ApplicationController
|
||||||
skip_before_action :verify_authenticity_token, only: [:create]
|
skip_before_action :verify_authenticity_token, only: [:create]
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_dependency 'discourse'
|
require_dependency 'discourse'
|
||||||
|
|
||||||
module DiscourseDonations
|
module DiscourseDonations
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
load File.expand_path('../regular/donation_user.rb', __FILE__)
|
load File.expand_path('../regular/donation_user.rb', __FILE__)
|
||||||
load File.expand_path('../scheduled/update_category_donation_statistics.rb', __FILE__)
|
load File.expand_path('../scheduled/update_category_donation_statistics.rb', __FILE__)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Jobs
|
module Jobs
|
||||||
class DonationUser < ::Jobs::Base
|
class DonationUser < ::Jobs::Base
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Jobs
|
module Jobs
|
||||||
class UpdateCategoryDonationStatistics < ::Jobs::Scheduled
|
class UpdateCategoryDonationStatistics < ::Jobs::Scheduled
|
||||||
every 1.day
|
every 1.day
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module DiscourseDonations
|
module DiscourseDonations
|
||||||
class Rewards
|
class Rewards
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module DiscourseDonations
|
module DiscourseDonations
|
||||||
class Stripe
|
class Stripe
|
||||||
attr_reader :charge, :currency, :description
|
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/rewards.rb', __FILE__)
|
||||||
load File.expand_path('../discourse_donations/stripe.rb', __FILE__)
|
load File.expand_path('../discourse_donations/stripe.rb', __FILE__)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
DiscourseDonations::Engine.routes.draw do
|
DiscourseDonations::Engine.routes.draw do
|
||||||
get '/' => 'charges#index'
|
get '/' => 'charges#index'
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ::DiscourseDonations
|
module ::DiscourseDonations
|
||||||
class Engine < ::Rails::Engine
|
class Engine < ::Rails::Engine
|
||||||
engine_name 'discourse-donations'
|
engine_name 'discourse-donations'
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# name: discourse-donations
|
# name: discourse-donations
|
||||||
# about: Integrates Stripe into Discourse to allow forum visitors to make donations
|
# about: Integrates Stripe into Discourse to allow forum visitors to make donations
|
||||||
# version: 1.11.3
|
# version: 1.11.3
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
shared_examples 'failure response' do |message_key|
|
shared_examples 'failure response' do |message_key|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Fabricator(:stripe_charge, from: "DiscourseDonations::StripeResponse") do
|
Fabricator(:stripe_charge, from: "DiscourseDonations::StripeResponse") do
|
||||||
response = {
|
response = {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Fabricator(:stripe_customer, from: "DiscourseDonations::StripeResponse") do
|
Fabricator(:stripe_customer, from: "DiscourseDonations::StripeResponse") do
|
||||||
response = {
|
response = {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Fabricator(:stripe_invoices, from: "DiscourseDonations::StripeResponse") do
|
Fabricator(:stripe_invoices, from: "DiscourseDonations::StripeResponse") do
|
||||||
response = {
|
response = {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Fabricator(:stripe_plans, from: "DiscourseDonations::StripeResponse") do
|
Fabricator(:stripe_plans, from: "DiscourseDonations::StripeResponse") do
|
||||||
response = {
|
response = {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Fabricator(:stripe_products, from: "DiscourseDonations::StripeResponse") do
|
Fabricator(:stripe_products, from: "DiscourseDonations::StripeResponse") do
|
||||||
response = {
|
response = {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# This is for building http responses with Fabricate
|
# This is for building http responses with Fabricate
|
||||||
# Usage: Fabricate(:customer).to_json
|
# Usage: Fabricate(:customer).to_json
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Fabricator(:stripe_subscription, from: "DiscourseDonations::StripeResponse") do
|
Fabricator(:stripe_subscription, from: "DiscourseDonations::StripeResponse") do
|
||||||
response = {
|
response = {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Jobs::DonationUser, type: :job do
|
RSpec.describe Jobs::DonationUser, type: :job do
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_relative './fabricators/charge_fabricator.rb'
|
require_relative './fabricators/charge_fabricator.rb'
|
||||||
require_relative './fabricators/customer_fabricator.rb'
|
require_relative './fabricators/customer_fabricator.rb'
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
module DiscourseDonations
|
module DiscourseDonations
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
require_relative '../../support/dd_helper'
|
require_relative '../../support/dd_helper'
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ module DiscourseDonations
|
|||||||
description: stripe_options[:description],
|
description: stripe_options[:description],
|
||||||
currency: stripe_options[:currency],
|
currency: stripe_options[:currency],
|
||||||
receipt_email: customer.email,
|
receipt_email: customer.email,
|
||||||
:metadata => { :discourse_cause => nil }
|
metadata: { discourse_cause: nil }
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ module DiscourseDonations
|
|||||||
it 'is successful' do
|
it 'is successful' do
|
||||||
::Stripe::Charge.expects(:create).with(charge_options).returns(paid: true)
|
::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)
|
subject.charge(nil, params)
|
||||||
expect(subject).to be_successful
|
expect(subject).to be_successful
|
||||||
@ -80,7 +82,7 @@ module DiscourseDonations
|
|||||||
|
|
||||||
it 'is not successful' do
|
it 'is not successful' do
|
||||||
::Stripe::Charge.expects(:create).with(charge_options).returns(paid: false)
|
::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)
|
subject.charge(nil, params)
|
||||||
expect(subject).not_to be_successful
|
expect(subject).not_to be_successful
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'fakeweb'
|
require 'fakeweb'
|
||||||
|
|
||||||
#TODO register some fixtures
|
#TODO register some fixtures
|
||||||
|
|
||||||
FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/customers',
|
FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/customers',
|
||||||
:body => '{
|
body: '{
|
||||||
"id": "cus_AJqrL4OU1sffPl",
|
"id": "cus_AJqrL4OU1sffPl",
|
||||||
"object": "customer",
|
"object": "customer",
|
||||||
"account_balance": 0,
|
"account_balance": 0,
|
||||||
@ -52,11 +54,11 @@ FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/customers',
|
|||||||
"url": "/v1/customers/cus_AJqrL4OU1sffPl/sources"
|
"url": "/v1/customers/cus_AJqrL4OU1sffPl/sources"
|
||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
:status => ['200', 'OK']
|
status: ['200', 'OK']
|
||||||
)
|
)
|
||||||
|
|
||||||
FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/charges',
|
FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/charges',
|
||||||
:body => '{
|
body: '{
|
||||||
"id": "ch_19zDAFEfVxQsvRbHtAwsCvV0",
|
"id": "ch_19zDAFEfVxQsvRbHtAwsCvV0",
|
||||||
"object": "charge",
|
"object": "charge",
|
||||||
"amount": 100,
|
"amount": 100,
|
||||||
@ -133,5 +135,5 @@ FakeWeb.register_uri(:post, 'https://api.stripe.com/v1/charges',
|
|||||||
"status": "succeeded",
|
"status": "succeeded",
|
||||||
"transfer_group": null
|
"transfer_group": null
|
||||||
}',
|
}',
|
||||||
:status => ['200', 'OK']
|
status: ['200', 'OK']
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user