diff options
author | Alessandro Desantis <desa.alessandro@gmail.com> | 2020-09-24 14:23:54 +0200 |
---|---|---|
committer | Alessandro Desantis <desa.alessandro@gmail.com> | 2020-09-25 11:52:52 +0200 |
commit | a98ab3aeefca1b679376b6e05b91f5a516f8d802 (patch) | |
tree | 74312a78db6d2948d9d6129c9823c82195ea9072 /lib/solidus_subscriptions | |
parent | c2ff76ed6f1b9aa377f566d7d98e743446919c0a (diff) |
Fix coding style violations
Diffstat (limited to 'lib/solidus_subscriptions')
14 files changed, 47 insertions, 23 deletions
diff --git a/lib/solidus_subscriptions/ability.rb b/lib/solidus_subscriptions/ability.rb index 38699cd..6ce4b2d 100644 --- a/lib/solidus_subscriptions/ability.rb +++ b/lib/solidus_subscriptions/ability.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusSubscriptions class Ability include CanCan::Ability diff --git a/lib/solidus_subscriptions/configuration.rb b/lib/solidus_subscriptions/configuration.rb index d128198..7743295 100644 --- a/lib/solidus_subscriptions/configuration.rb +++ b/lib/solidus_subscriptions/configuration.rb @@ -1,52 +1,52 @@ +# frozen_string_literal: true + module SolidusSubscriptions class Configuration - attr_writer :success_dispatcher_class + attr_accessor :maximum_total_skips + + attr_writer( + :success_dispatcher_class, :failure_dispatcher_class, :payment_failed_dispatcher_class, + :out_of_stock_dispatcher, :maximum_successive_skips, :reprocessing_interval, + :minimum_cancellation_notice, :processing_queue, :subscription_line_item_attributes, + :subscription_attributes, + ) + def success_dispatcher_class @success_dispatcher_class ||= 'SolidusSubscriptions::SuccessDispatcher' @success_dispatcher_class.constantize end - attr_writer :failure_dispatcher_class def failure_dispatcher_class @failure_dispatcher_class ||= 'SolidusSubscriptions::FailureDispatcher' @failure_dispatcher_class.constantize end - attr_writer :payment_failed_dispatcher_class def payment_failed_dispatcher_class @payment_failed_dispatcher_class ||= 'SolidusSubscriptions::PaymentFailedDispatcher' @payment_failed_dispatcher_class.constantize end - attr_writer :out_of_stock_dispatcher def out_of_stock_dispatcher_class @out_of_stock_dispatcher_class ||= 'SolidusSubscriptions::OutOfStockDispatcher' @out_of_stock_dispatcher_class.constantize end - attr_writer :maximum_successive_skips def maximum_successive_skips @maximum_successive_skips ||= 1 end - attr_accessor :maximum_total_skips - - attr_writer :reprocessing_interval def reprocessing_interval @reprocessing_interval ||= 1.day end - attr_writer :minimum_cancellation_notice def minimum_cancellation_notice @minimum_cancellation_notice ||= 1.day end - attr_writer :processing_queue def processing_queue @processing_queue ||= :default end - attr_writer :subscription_line_item_attributes def subscription_line_item_attributes @subscription_line_item_attributes ||= [ :quantity, @@ -57,15 +57,14 @@ module SolidusSubscriptions ] end - attr_writer :subscription_attributes def subscription_attributes @subscription_attributes ||= [ :interval_length, :interval_units, :end_date, :actionable_date, - shipping_address_attributes: Spree::PermittedAttributes.address_attributes, - billing_address_attributes: Spree::PermittedAttributes.address_attributes, + { shipping_address_attributes: Spree::PermittedAttributes.address_attributes, + billing_address_attributes: Spree::PermittedAttributes.address_attributes }, ] end end diff --git a/lib/solidus_subscriptions/engine.rb b/lib/solidus_subscriptions/engine.rb index 0f18d95..ad43db3 100644 --- a/lib/solidus_subscriptions/engine.rb +++ b/lib/solidus_subscriptions/engine.rb @@ -37,6 +37,7 @@ module SolidusSubscriptions initializer 'solidus_subscriptions.configure_backend' do next unless ::Spree::Backend::Config.respond_to?(:menu_items) + ::Spree::Backend::Config.configure do |config| config.menu_items << config.class::MenuItem.new( [:subscriptions], diff --git a/lib/solidus_subscriptions/permitted_attributes.rb b/lib/solidus_subscriptions/permitted_attributes.rb index f689e90..d9ec072 100644 --- a/lib/solidus_subscriptions/permitted_attributes.rb +++ b/lib/solidus_subscriptions/permitted_attributes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This module is responsible for managing what attributes can be updated # through the api. It also overrides Spree::Permitted attributes to allow the # solidus api to accept nested params for subscription models as well diff --git a/lib/solidus_subscriptions/processor.rb b/lib/solidus_subscriptions/processor.rb index be8a2f5..817d957 100644 --- a/lib/solidus_subscriptions/processor.rb +++ b/lib/solidus_subscriptions/processor.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class is responsible for finding subscriptions and installments # which need to be processed. It will group them together by user and attempts # to process them together. Subscriptions will also be grouped by their @@ -61,7 +63,7 @@ module SolidusSubscriptions [i.subscription.shipping_address_id, i.subscription.billing_address_id] end - installemts_by_address_and_user.values.each do |grouped_installments| + installemts_by_address_and_user.each_value do |grouped_installments| ProcessInstallmentsJob.perform_later grouped_installments.map(&:id) end end @@ -71,18 +73,18 @@ module SolidusSubscriptions def subscriptions_by_id @subscriptions_by_id ||= Subscription. - actionable. - includes(:line_items, :user). - where(user_id: user_ids). - group_by(&:user_id) + actionable. + includes(:line_items, :user). + where(user_id: user_ids). + group_by(&:user_id) end def retry_installments @failed_installments ||= Installment. - actionable. - includes(:subscription). - where(solidus_subscriptions_subscriptions: { user_id: user_ids }). - group_by { |i| i.subscription.user_id } + actionable. + includes(:subscription). + where(solidus_subscriptions_subscriptions: { user_id: user_ids }). + group_by { |i| i.subscription.user_id } end def installments(user) diff --git a/lib/solidus_subscriptions/testing_support/factories.rb b/lib/solidus_subscriptions/testing_support/factories.rb index 8423e0d..c19a785 100644 --- a/lib/solidus_subscriptions/testing_support/factories.rb +++ b/lib/solidus_subscriptions/testing_support/factories.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'factory_bot' require 'spree/testing_support/factories' diff --git a/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb b/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb index 6f90bf7..6910c0f 100644 --- a/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb +++ b/lib/solidus_subscriptions/testing_support/factories/installment_detail_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :installment_detail, class: 'SolidusSubscriptions::InstallmentDetail' do installment diff --git a/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb b/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb index 9914019..2eb5069 100644 --- a/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb +++ b/lib/solidus_subscriptions/testing_support/factories/installment_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :installment, class: 'SolidusSubscriptions::Installment' do transient { diff --git a/lib/solidus_subscriptions/testing_support/factories/line_item_factory.rb b/lib/solidus_subscriptions/testing_support/factories/line_item_factory.rb index 51926a6..8d454d6 100644 --- a/lib/solidus_subscriptions/testing_support/factories/line_item_factory.rb +++ b/lib/solidus_subscriptions/testing_support/factories/line_item_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :subscription_line_item, class: 'SolidusSubscriptions::LineItem' do subscribable_id { create(:variant, subscribable: true).id } diff --git a/lib/solidus_subscriptions/testing_support/factories/spree/line_item_factory.rb b/lib/solidus_subscriptions/testing_support/factories/spree/line_item_factory.rb index c9d1012..c0dcf1e 100644 --- a/lib/solidus_subscriptions/testing_support/factories/spree/line_item_factory.rb +++ b/lib/solidus_subscriptions/testing_support/factories/spree/line_item_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.modify do factory :line_item do trait :with_subscription_line_items do diff --git a/lib/solidus_subscriptions/testing_support/factories/spree/order_factory.rb b/lib/solidus_subscriptions/testing_support/factories/spree/order_factory.rb index 3eca360..ed51e3f 100644 --- a/lib/solidus_subscriptions/testing_support/factories/spree/order_factory.rb +++ b/lib/solidus_subscriptions/testing_support/factories/spree/order_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.modify do factory :order do trait :with_subscription_line_items do diff --git a/lib/solidus_subscriptions/testing_support/factories/spree_modification_factory.rb b/lib/solidus_subscriptions/testing_support/factories/spree_modification_factory.rb index 39e0e46..9870d85 100644 --- a/lib/solidus_subscriptions/testing_support/factories/spree_modification_factory.rb +++ b/lib/solidus_subscriptions/testing_support/factories/spree_modification_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.modify do factory :user do trait :subscription_user do diff --git a/lib/solidus_subscriptions/testing_support/factories/subscription_event_factory.rb b/lib/solidus_subscriptions/testing_support/factories/subscription_event_factory.rb index 0158e2e..8504037 100644 --- a/lib/solidus_subscriptions/testing_support/factories/subscription_event_factory.rb +++ b/lib/solidus_subscriptions/testing_support/factories/subscription_event_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :subscription_event, class: 'SolidusSubscriptions::SubscriptionEvent' do subscription diff --git a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb index 8660b13..2898d36 100644 --- a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb +++ b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + FactoryBot.define do factory :subscription, class: 'SolidusSubscriptions::Subscription' do store |