diff --git a/.rubocop.yml b/.rubocop.yml index ff338fa..5aa2c9f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,7 @@ AllCops: Exclude: - 'spec/dummy/**/*' - 'vendor/bundle/**/*' - TargetRubyVersion: 2.1 + TargetRubyVersion: 2.3 # Sometimes I believe this reads better # This also causes spacing issues on multi-line fixes @@ -38,9 +38,6 @@ Style/WordArray: Style/ConditionalAssignment: Enabled: false -Performance/Count: - Enabled: false - Style/RaiseArgs: Enabled: false @@ -73,10 +70,10 @@ Layout/ClosingParenthesisIndentation: Layout/MultilineMethodCallIndentation: Enabled: false -Layout/IndentArray: +Layout/IndentFirstArrayElement: Enabled: false -Layout/IndentHash: +Layout/IndentFirstHashElement: Enabled: false Layout/AlignHash: diff --git a/Gemfile b/Gemfile index 62f0568..9095834 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'https://rubygems.org' branch = ENV.fetch('SOLIDUS_BRANCH', 'v2.2') diff --git a/Rakefile b/Rakefile index b3e521f..c1f880c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler' Bundler::GemHelper.install_tasks diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index 7267a58..800e5af 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusPaybright module CheckoutControllerDecorator def update diff --git a/app/controllers/spree/paybright_controller.rb b/app/controllers/spree/paybright_controller.rb index c2a31ec..27548ac 100644 --- a/app/controllers/spree/paybright_controller.rb +++ b/app/controllers/spree/paybright_controller.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Spree class PaybrightController < Spree::BaseController # We can't use CSRF protection on a route that's hit by an external service @@ -36,6 +38,7 @@ def paybright_params def redirect_path(order) return cart_path unless order + order.complete? ? order_path(order) : checkout_state_path(order.state) end diff --git a/app/models/solidus_paybright/configuration.rb b/app/models/solidus_paybright/configuration.rb index f0f324d..17fff76 100644 --- a/app/models/solidus_paybright/configuration.rb +++ b/app/models/solidus_paybright/configuration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusPaybright class Configuration < Spree::Preferences::Configuration attr_writer :test_redirect_url diff --git a/app/models/spree/payment_decorator.rb b/app/models/spree/payment_decorator.rb index 473ad2b..a057453 100644 --- a/app/models/spree/payment_decorator.rb +++ b/app/models/spree/payment_decorator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusPaybright module PaymentDecorator def redirect_url diff --git a/app/models/spree/payment_method/paybright.rb b/app/models/spree/payment_method/paybright.rb index 7998006..8170133 100644 --- a/app/models/spree/payment_method/paybright.rb +++ b/app/models/spree/payment_method/paybright.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Spree class PaymentMethod::Paybright < Spree::PaymentMethod preference :api_key, :string diff --git a/app/models/spree/payment_method_decorator.rb b/app/models/spree/payment_method_decorator.rb index 78e7cfb..4885eda 100644 --- a/app/models/spree/payment_method_decorator.rb +++ b/app/models/spree/payment_method_decorator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusPaybright module PaymentMethodDecorator def redirect_url(_payment) diff --git a/config/routes.rb b/config/routes.rb index f63d544..8f45cdb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Spree::Core::Engine.routes.draw do post "/paybright/callback", to: "paybright#callback", as: :paybright_callback get "/paybright/cancel/:payment_id", to: "paybright#cancel", as: :paybright_cancel diff --git a/lib/generators/solidus_paybright/install/install_generator.rb b/lib/generators/solidus_paybright/install/install_generator.rb index f3aa3e8..fae7ed1 100644 --- a/lib/generators/solidus_paybright/install/install_generator.rb +++ b/lib/generators/solidus_paybright/install/install_generator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusPaybright module Generators class InstallGenerator < Rails::Generators::Base diff --git a/lib/solidus_paybright.rb b/lib/solidus_paybright.rb index ec02f6c..b17e630 100644 --- a/lib/solidus_paybright.rb +++ b/lib/solidus_paybright.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'solidus_core' require 'solidus_support' require 'solidus_paybright/engine' diff --git a/lib/solidus_paybright/api_client.rb b/lib/solidus_paybright/api_client.rb index 31c3ec1..38fca3b 100644 --- a/lib/solidus_paybright/api_client.rb +++ b/lib/solidus_paybright/api_client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "typhoeus" require "securerandom" require "digest" diff --git a/lib/solidus_paybright/callback_validator.rb b/lib/solidus_paybright/callback_validator.rb index 6556f06..ba2598b 100644 --- a/lib/solidus_paybright/callback_validator.rb +++ b/lib/solidus_paybright/callback_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusPaybright class CallbackValidator # @param params [Hash] The Paybright callback params diff --git a/lib/solidus_paybright/engine.rb b/lib/solidus_paybright/engine.rb index d99bb2c..ce7aa43 100644 --- a/lib/solidus_paybright/engine.rb +++ b/lib/solidus_paybright/engine.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusPaybright class Engine < Rails::Engine require 'spree/core' diff --git a/lib/solidus_paybright/factories.rb b/lib/solidus_paybright/factories.rb index 2240093..47af483 100644 --- a/lib/solidus_paybright/factories.rb +++ b/lib/solidus_paybright/factories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :paybright_payment_method, class: Spree::PaymentMethod::Paybright do name "Paybright" diff --git a/lib/solidus_paybright/params_helper.rb b/lib/solidus_paybright/params_helper.rb index 9fb200b..c238389 100644 --- a/lib/solidus_paybright/params_helper.rb +++ b/lib/solidus_paybright/params_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusPaybright class ParamsHelper include Spree::Core::Engine.routes.url_helpers diff --git a/lib/solidus_paybright/signing_helper.rb b/lib/solidus_paybright/signing_helper.rb index cbeb083..8add476 100644 --- a/lib/solidus_paybright/signing_helper.rb +++ b/lib/solidus_paybright/signing_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "openssl" module SolidusPaybright diff --git a/lib/solidus_paybright/version.rb b/lib/solidus_paybright/version.rb index 56c3a06..67fa207 100644 --- a/lib/solidus_paybright/version.rb +++ b/lib/solidus_paybright/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusPaybright VERSION = '1.1.0' end diff --git a/solidus_paybright.gemspec b/solidus_paybright.gemspec index b84eb2f..5bfee7e 100644 --- a/solidus_paybright.gemspec +++ b/solidus_paybright.gemspec @@ -1,4 +1,6 @@ -$:.push File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +$:.push File.expand_path('lib', __dir__) require 'solidus_paybright/version' Gem::Specification.new do |s| diff --git a/spec/controllers/spree/checkout_controller_spec.rb b/spec/controllers/spree/checkout_controller_spec.rb index 1dffd16..18fc83d 100644 --- a/spec/controllers/spree/checkout_controller_spec.rb +++ b/spec/controllers/spree/checkout_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Spree::CheckoutController, type: :controller do diff --git a/spec/controllers/spree/paybright_controller_spec.rb b/spec/controllers/spree/paybright_controller_spec.rb index c584179..950877c 100644 --- a/spec/controllers/spree/paybright_controller_spec.rb +++ b/spec/controllers/spree/paybright_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Spree::PaybrightController, type: :controller do diff --git a/spec/lib/solidus_paybright/api_client_spec.rb b/spec/lib/solidus_paybright/api_client_spec.rb index 5def615..7b3113e 100644 --- a/spec/lib/solidus_paybright/api_client_spec.rb +++ b/spec/lib/solidus_paybright/api_client_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe SolidusPaybright::ApiClient do diff --git a/spec/lib/solidus_paybright/params_helper_spec.rb b/spec/lib/solidus_paybright/params_helper_spec.rb index fe3cd90..d271710 100644 --- a/spec/lib/solidus_paybright/params_helper_spec.rb +++ b/spec/lib/solidus_paybright/params_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe SolidusPaybright::ParamsHelper do diff --git a/spec/lib/solidus_paybright/signing_helper_spec.rb b/spec/lib/solidus_paybright/signing_helper_spec.rb index 20bac96..404c313 100644 --- a/spec/lib/solidus_paybright/signing_helper_spec.rb +++ b/spec/lib/solidus_paybright/signing_helper_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe SolidusPaybright::SigningHelper do diff --git a/spec/models/spree/payment_method/paybright_spec.rb b/spec/models/spree/payment_method/paybright_spec.rb index e1b1874..4ba977e 100644 --- a/spec/models/spree/payment_method/paybright_spec.rb +++ b/spec/models/spree/payment_method/paybright_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "spec_helper" describe Spree::PaymentMethod::Paybright, type: :model do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5a742d4..65b0ae3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Run Coverage report require 'simplecov' SimpleCov.start do @@ -13,7 +15,7 @@ # Configure Rails Environment ENV['RAILS_ENV'] = 'test' -require File.expand_path('../dummy/config/environment.rb', __FILE__) +require File.expand_path('dummy/config/environment.rb', __dir__) require 'rspec/rails' require 'database_cleaner'