diff --git a/app/controllers/controllers.rb b/app/controllers/controllers.rb index d11f590..46b553e 100644 --- a/app/controllers/controllers.rb +++ b/app/controllers/controllers.rb @@ -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__) diff --git a/app/controllers/discourse_donations/charges_controller.rb b/app/controllers/discourse_donations/charges_controller.rb index 6835543..d182ce0 100644 --- a/app/controllers/discourse_donations/charges_controller.rb +++ b/app/controllers/discourse_donations/charges_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DiscourseDonations class ChargesController < ::ApplicationController skip_before_action :verify_authenticity_token, only: [:create] diff --git a/app/controllers/discourse_donations/checkout_controller.rb b/app/controllers/discourse_donations/checkout_controller.rb index 946729c..24206e1 100644 --- a/app/controllers/discourse_donations/checkout_controller.rb +++ b/app/controllers/discourse_donations/checkout_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_dependency 'discourse' module DiscourseDonations diff --git a/app/jobs/jobs.rb b/app/jobs/jobs.rb index 1a1620c..5c38931 100644 --- a/app/jobs/jobs.rb +++ b/app/jobs/jobs.rb @@ -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__) diff --git a/app/jobs/regular/donation_user.rb b/app/jobs/regular/donation_user.rb index 5f28c78..88ea75d 100644 --- a/app/jobs/regular/donation_user.rb +++ b/app/jobs/regular/donation_user.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Jobs class DonationUser < ::Jobs::Base diff --git a/app/jobs/scheduled/update_category_donation_statistics.rb b/app/jobs/scheduled/update_category_donation_statistics.rb index 0d338a8..5046656 100644 --- a/app/jobs/scheduled/update_category_donation_statistics.rb +++ b/app/jobs/scheduled/update_category_donation_statistics.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Jobs class UpdateCategoryDonationStatistics < ::Jobs::Scheduled every 1.day diff --git a/app/services/discourse_donations/rewards.rb b/app/services/discourse_donations/rewards.rb index 7b2dca1..93596c4 100644 --- a/app/services/discourse_donations/rewards.rb +++ b/app/services/discourse_donations/rewards.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module DiscourseDonations class Rewards diff --git a/app/services/discourse_donations/stripe.rb b/app/services/discourse_donations/stripe.rb index a988d25..199d59e 100644 --- a/app/services/discourse_donations/stripe.rb +++ b/app/services/discourse_donations/stripe.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module DiscourseDonations class Stripe attr_reader :charge, :currency, :description diff --git a/app/services/services.rb b/app/services/services.rb index 8e8aabc..73924a0 100644 --- a/app/services/services.rb +++ b/app/services/services.rb @@ -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__) diff --git a/config/routes.rb b/config/routes.rb index b08fab8..5314102 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + DiscourseDonations::Engine.routes.draw do get '/' => 'charges#index' diff --git a/lib/discourse_donations/engine.rb b/lib/discourse_donations/engine.rb index d92e065..41a41c5 100644 --- a/lib/discourse_donations/engine.rb +++ b/lib/discourse_donations/engine.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ::DiscourseDonations class Engine < ::Rails::Engine engine_name 'discourse-donations' diff --git a/plugin.rb b/plugin.rb index c24ba1b..f03ce5f 100644 --- a/plugin.rb +++ b/plugin.rb @@ -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 diff --git a/spec/controllers/discourse_donations/charges_controller_spec.rb b/spec/controllers/discourse_donations/charges_controller_spec.rb index a0342e1..edd70f8 100644 --- a/spec/controllers/discourse_donations/charges_controller_spec.rb +++ b/spec/controllers/discourse_donations/charges_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' shared_examples 'failure response' do |message_key| diff --git a/spec/fabricators/charge_fabricator.rb b/spec/fabricators/charge_fabricator.rb index e45e8eb..9a08a61 100644 --- a/spec/fabricators/charge_fabricator.rb +++ b/spec/fabricators/charge_fabricator.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true Fabricator(:stripe_charge, from: "DiscourseDonations::StripeResponse") do response = { diff --git a/spec/fabricators/customer_fabricator.rb b/spec/fabricators/customer_fabricator.rb index e306e69..6222092 100644 --- a/spec/fabricators/customer_fabricator.rb +++ b/spec/fabricators/customer_fabricator.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true Fabricator(:stripe_customer, from: "DiscourseDonations::StripeResponse") do response = { diff --git a/spec/fabricators/invoices_fabricator.rb b/spec/fabricators/invoices_fabricator.rb index 6d8630e..d4c823c 100644 --- a/spec/fabricators/invoices_fabricator.rb +++ b/spec/fabricators/invoices_fabricator.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true Fabricator(:stripe_invoices, from: "DiscourseDonations::StripeResponse") do response = { diff --git a/spec/fabricators/plans_fabricator.rb b/spec/fabricators/plans_fabricator.rb index a88f19a..cd4effd 100644 --- a/spec/fabricators/plans_fabricator.rb +++ b/spec/fabricators/plans_fabricator.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true Fabricator(:stripe_plans, from: "DiscourseDonations::StripeResponse") do response = { diff --git a/spec/fabricators/products_fabricator.rb b/spec/fabricators/products_fabricator.rb index 6da49a4..ff9cbcf 100644 --- a/spec/fabricators/products_fabricator.rb +++ b/spec/fabricators/products_fabricator.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true Fabricator(:stripe_products, from: "DiscourseDonations::StripeResponse") do response = { diff --git a/spec/fabricators/stripe_response.rb b/spec/fabricators/stripe_response.rb index 5e68f95..6649fad 100644 --- a/spec/fabricators/stripe_response.rb +++ b/spec/fabricators/stripe_response.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # This is for building http responses with Fabricate # Usage: Fabricate(:customer).to_json diff --git a/spec/fabricators/subscription_fabricator.rb b/spec/fabricators/subscription_fabricator.rb index c6d76b8..75a716d 100644 --- a/spec/fabricators/subscription_fabricator.rb +++ b/spec/fabricators/subscription_fabricator.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true Fabricator(:stripe_subscription, from: "DiscourseDonations::StripeResponse") do response = { diff --git a/spec/jobs/regular/donation_user_spec.rb b/spec/jobs/regular/donation_user_spec.rb index cdaef35..fa09fea 100644 --- a/spec/jobs/regular/donation_user_spec.rb +++ b/spec/jobs/regular/donation_user_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' RSpec.describe Jobs::DonationUser, type: :job do diff --git a/spec/plugin_helper.rb b/spec/plugin_helper.rb index ecab67d..aa3fb30 100644 --- a/spec/plugin_helper.rb +++ b/spec/plugin_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require_relative './fabricators/charge_fabricator.rb' require_relative './fabricators/customer_fabricator.rb' diff --git a/spec/services/discourse_donations/rewards_spec.rb b/spec/services/discourse_donations/rewards_spec.rb index f2ce760..f39956b 100644 --- a/spec/services/discourse_donations/rewards_spec.rb +++ b/spec/services/discourse_donations/rewards_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' module DiscourseDonations diff --git a/spec/services/discourse_donations/stripe_spec.rb b/spec/services/discourse_donations/stripe_spec.rb index 5cc1b36..f49e1fe 100644 --- a/spec/services/discourse_donations/stripe_spec.rb +++ b/spec/services/discourse_donations/stripe_spec.rb @@ -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 diff --git a/spec/support/dd_helper.rb b/spec/support/dd_helper.rb index 3c196f0..051d6fb 100644 --- a/spec/support/dd_helper.rb +++ b/spec/support/dd_helper.rb @@ -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'] )