diff options
48 files changed, 277 insertions, 210 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4edc2f5..195ab44 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,12 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 -Lint/AmbiguousBlockAssociation: - Exclude: - - 'spec/controllers/spree/admin/subscriptions_controller_spec.rb' - - 'spec/services/solidus_subscriptions/checkout_spec.rb' - # Offense count: 1 Lint/MissingSuper: Exclude: @@ -24,69 +18,10 @@ Naming/MemoizedInstanceVariableName: Exclude: - 'lib/solidus_subscriptions/processor.rb' -# Offense count: 1 -RSpec/AnyInstance: - Exclude: - - 'spec/jobs/solidus_subscriptions/process_installments_job_spec.rb' - -# Offense count: 46 -# Configuration parameters: Prefixes. -# Prefixes: when, with, without -RSpec/ContextWording: - Exclude: - - 'spec/controllers/solidus_subscriptions/api/v1/line_items_controller_spec.rb' - - 'spec/controllers/spree/admin/subscriptions_controller_spec.rb' - - 'spec/lib/solidus_subscriptions/ability_spec.rb' - - 'spec/lib/solidus_subscriptions/processor_spec.rb' - - 'spec/models/solidus_subscriptions/installment_detail_spec.rb' - - 'spec/models/solidus_subscriptions/installment_spec.rb' - - 'spec/models/solidus_subscriptions/line_item_spec.rb' - - 'spec/models/solidus_subscriptions/subscription_spec.rb' - - 'spec/services/solidus_subscriptions/checkout_spec.rb' - - 'spec/services/solidus_subscriptions/line_item_builder_spec.rb' - - 'spec/services/solidus_subscriptions/order_builder_spec.rb' - -# Offense count: 2 -# Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly. -RSpec/FilePath: - Exclude: - - 'spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscrptions_spec.rb' - - 'spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions.rb' - -# Offense count: 1 -# Configuration parameters: AssignmentOnly. -RSpec/InstanceVariable: - Exclude: - - 'spec/services/solidus_subscriptions/checkout_spec.rb' - -# Offense count: 18 -RSpec/LetSetup: - Exclude: - - 'spec/controllers/solidus_subscriptions/api/v1/subscriptions_controller_spec.rb' - - 'spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb' - - 'spec/lib/solidus_subscriptions/processor_spec.rb' - - 'spec/services/solidus_subscriptions/checkout_spec.rb' - - 'spec/services/solidus_subscriptions/line_item_builder_spec.rb' - -# Offense count: 8 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: have_received, receive -RSpec/MessageSpies: - Exclude: - - 'spec/services/solidus_subscriptions/failure_dispatcher_spec.rb' - - 'spec/services/solidus_subscriptions/out_of_stock_dispatcher_spec.rb' - - 'spec/services/solidus_subscriptions/payment_failed_dispatcher_spec.rb' - - 'spec/services/solidus_subscriptions/success_dispatcher_spec.rb' - # Offense count: 2 RSpec/MultipleExpectations: Max: 2 -# Offense count: 27 -# Configuration parameters: AllowSubject. -RSpec/MultipleMemoizedHelpers: - Max: 14 - # Offense count: 90 # Configuration parameters: IgnoreSharedExamples. RSpec/NamedSubject: @@ -120,7 +55,6 @@ Rails/SkipsModelValidations: - 'app/services/solidus_subscriptions/failure_dispatcher.rb' - 'app/services/solidus_subscriptions/order_builder.rb' - 'app/services/solidus_subscriptions/payment_failed_dispatcher.rb' - - 'spec/services/solidus_subscriptions/checkout_spec.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -90,6 +90,11 @@ The task creates ActiveJob jobs which can be fulfilled by your queue library of We suggest using the [Whenever](https://github.com/javan/whenever) gem to schedule the task. +### Promotion rules +This extensions adds the following [Promotion rules](https://guides.solidus.io/developers/promotions/promotion-rules.html): +* `SolidusSubscriptions::Promotion::Rules::SubscriptionCreationOrder` which applies if the order is creating a subscription; +* `SolidusSubscriptions::Promotion::Rules::SubscriptionInstallmentOrder` which applies if the order is an installment of a subscription. + ### API documentation You can find the API documentation [here](https://stoplight.io/p/docs/gh/solidusio-contrib/solidus_subscriptions?group=master). diff --git a/app/jobs/solidus_subscriptions/process_installment_job.rb b/app/jobs/solidus_subscriptions/process_installment_job.rb index 127c787..53270e5 100644 --- a/app/jobs/solidus_subscriptions/process_installment_job.rb +++ b/app/jobs/solidus_subscriptions/process_installment_job.rb @@ -6,6 +6,8 @@ module SolidusSubscriptions def perform(installment) Checkout.new(installment).process + rescue StandardError => e + SolidusSubscriptions.configuration.processing_error_handler&.call(e) end end end diff --git a/app/models/solidus_subscriptions/promotion/rules/subscription_creation_order.rb b/app/models/solidus_subscriptions/promotion/rules/subscription_creation_order.rb new file mode 100644 index 0000000..1b44125 --- /dev/null +++ b/app/models/solidus_subscriptions/promotion/rules/subscription_creation_order.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module SolidusSubscriptions + module Promotion + module Rules + class SubscriptionCreationOrder < ::Spree::PromotionRule + # Promotion can be applied to an entire order. Will only be true + # for Spree::Order + # + # @param promotable [Object] Any object which could have this + # promotion rule applied to it. + # + # @return [Boolean] + def applicable?(promotable) + promotable.is_a? ::Spree::Order + end + + # An order is eligible if it contains a line item with an associates + # subscription_line_item. This rule applies to order and so its eligibility + # will always be considered against an order. Will only return true for + # orders containing Spree::Line item with associated subscription_line_items + # + # @param order [Spree::Order] The order which could have this rule applied + # to it. + # + # @return [Boolean] + def eligible?(order, **_options) + order.subscription_line_items.any? + end + + # Certain actions create adjustments on line items. In this case, only + # line items with associated subscription_line_items are eligible to be + # adjusted. Will only return true # if :line_item has an associated + # subscription. + # + # @param line_item [Spree::LineItem] The line item which could be adjusted + # by the promotion. + def actionable?(line_item) + line_item.subscription_line_items.present? + end + end + end + end +end diff --git a/app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb b/app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb new file mode 100644 index 0000000..455825d --- /dev/null +++ b/app/models/solidus_subscriptions/promotion/rules/subscription_installment_order.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module SolidusSubscriptions + module Promotion + module Rules + class SubscriptionInstallmentOrder < ::Spree::PromotionRule + # Promotion can be applied to an entire order. Will only be true + # for Spree::Order + # + # @param promotable [Object] Any object which could have this + # promotion rule applied to it. + # + # @return [Boolean] + def applicable?(promotable) + promotable.is_a? ::Spree::Order + end + + # An order is eligible if it fulfills a subscription Installment. Will only + # return true if the order fulfills one or more Installments + # + # @param order [Spree::Order] The order which could have this rule applied + # to it. + # + # @return [Boolean] + def eligible?(order, **_options) + order.subscription_order? + end + end + end + end +end diff --git a/app/models/solidus_subscriptions/subscription_order_promotion_rule.rb b/app/models/solidus_subscriptions/subscription_order_promotion_rule.rb deleted file mode 100644 index 17d280e..0000000 --- a/app/models/solidus_subscriptions/subscription_order_promotion_rule.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -module SolidusSubscriptions - class SubscriptionOrderPromotionRule < ::Spree::PromotionRule - # Promotion can be applied to an entire order. Will only be true - # for Spree::Order - # - # @param promotable [Object] Any object which could have this - # promotion rule applied to it. - # - # @return [Boolean] - def applicable?(promotable) - promotable.is_a? ::Spree::Order - end - - # An order is eligible if it fulfills a subscription Installment. Will only - # return true if the order fulfills one or more Installments - # - # @param order [Spree::Order] The order which could have this rule applied - # to it. - # - # @return [Boolean] - def eligible?(order, **_options) - order.subscription_order? - end - end -end diff --git a/app/models/solidus_subscriptions/subscription_promotion_rule.rb b/app/models/solidus_subscriptions/subscription_promotion_rule.rb deleted file mode 100644 index fd99979..0000000 --- a/app/models/solidus_subscriptions/subscription_promotion_rule.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -module SolidusSubscriptions - class SubscriptionPromotionRule < ::Spree::PromotionRule - # Promotion can be applied to an entire order. Will only be true - # for Spree::Order - # - # @param promotable [Object] Any object which could have this - # promotion rule applied to it. - # - # @return [Boolean] - def applicable?(promotable) - promotable.is_a? ::Spree::Order - end - - # An order is eligible if it contains a line item with an associates - # subscription_line_item. This rule applies to order and so its eligibility - # will always be considered against an order. Will only return true for - # orders containing Spree::Line item with associated subscription_line_items - # - # @param order [Spree::Order] The order which could have this rule applied - # to it. - # - # @return [Boolean] - def eligible?(order, **_options) - order.subscription_line_items.any? - end - - # Certain actions create adjustments on line items. In this case, only - # line items with associated subscription_line_items are eligible to be - # adjusted. Will only return true # if :line_item has an associated - # subscription. - # - # @param line_item [Spree::LineItem] The line item which could be adjusted - # by the promotion. - def actionable?(line_item) - line_item.subscription_line_items.present? - end - end -end diff --git a/app/views/spree/admin/promotions/rules/_subscription_order_promotion_rule.html.erb b/app/views/spree/admin/promotions/rules/_subscription_creation_order.html.erb index e69de29..e69de29 100644 --- a/app/views/spree/admin/promotions/rules/_subscription_order_promotion_rule.html.erb +++ b/app/views/spree/admin/promotions/rules/_subscription_creation_order.html.erb diff --git a/app/views/spree/admin/promotions/rules/_subscription_promotion_rule.html.erb b/app/views/spree/admin/promotions/rules/_subscription_installment_order.html.erb index e69de29..e69de29 100644 --- a/app/views/spree/admin/promotions/rules/_subscription_promotion_rule.html.erb +++ b/app/views/spree/admin/promotions/rules/_subscription_installment_order.html.erb diff --git a/config/locales/en.yml b/config/locales/en.yml index 522a29e..79d400a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -97,6 +97,10 @@ en: solidus_subscriptions/installment/state: fulfilled: Fulfilled unfulfilled: Unfulfilled + solidus_subscriptions/promotion/rules/subscription_creation_order: + description: Creates a subscription + solidus_subscriptions/promotion/rules/subscription_installment_order: + description: Is a subscription installment models: solidus_subscriptions/subscription: one: Subscription diff --git a/db/migrate/20210323165714_update_promotion_rule_names.rb b/db/migrate/20210323165714_update_promotion_rule_names.rb new file mode 100644 index 0000000..f6ee6c2 --- /dev/null +++ b/db/migrate/20210323165714_update_promotion_rule_names.rb @@ -0,0 +1,22 @@ +class UpdatePromotionRuleNames < ActiveRecord::Migration[5.2] + TYPE_RENAMES = { + 'SolidusSubscriptions::SubscriptionPromotionRule' => 'SolidusSubscriptions::Promotion::Rules::SubscriptionCreationOrder', + 'SolidusSubscriptions::SubscriptionOrderPromotionRule' => 'SolidusSubscriptions::Promotion::Rules::SubscriptionInstallmentOrder', + }.freeze + + def change + reversible do |dir| + dir.up do + TYPE_RENAMES.each do |old_type, new_type| + Spree::PromotionRule.where(type: old_type).update(type: new_type) + end + end + + dir.down do + TYPE_RENAMES.each do |old_type, new_type| + Spree::PromotionRule.where(type: new_type).update(type: old_type) + end + end + end + end +end diff --git a/lib/generators/solidus_subscriptions/install/templates/initializer.rb b/lib/generators/solidus_subscriptions/install/templates/initializer.rb index 31e44b5..3632f08 100644 --- a/lib/generators/solidus_subscriptions/install/templates/initializer.rb +++ b/lib/generators/solidus_subscriptions/install/templates/initializer.rb @@ -26,6 +26,13 @@ SolidusSubscriptions.configure do |config| # failure cancel the subscription. # config.maximum_reprocessing_time = nil + # This custom error handler is called when a ProcessInstallmentJob `#perform` method fails. + # The rescued error can be managed as required via a Proc, such as one which logs the error + # on an error tracking system. + # Though not recommended due to the retry mechanisms built into this gem, the error can be + # re-raised if the default retry behaviour is required in ActiveJob. + # config.processing_error_handler = nil + # ========================================= Dispatchers ========================================== # # These dispatchers are pluggable. If you override any handlers, it is highly encouraged that you diff --git a/lib/solidus_subscriptions/configuration.rb b/lib/solidus_subscriptions/configuration.rb index 536aad3..cbaec5c 100644 --- a/lib/solidus_subscriptions/configuration.rb +++ b/lib/solidus_subscriptions/configuration.rb @@ -4,7 +4,7 @@ module SolidusSubscriptions class Configuration attr_accessor( :maximum_total_skips, :maximum_reprocessing_time, :churn_buster_account_id, - :churn_buster_api_key, :clear_past_installments, + :churn_buster_api_key, :clear_past_installments, :processing_error_handler, ) attr_writer( diff --git a/lib/solidus_subscriptions/engine.rb b/lib/solidus_subscriptions/engine.rb index 2f3067e..0f274d8 100644 --- a/lib/solidus_subscriptions/engine.rb +++ b/lib/solidus_subscriptions/engine.rb @@ -31,8 +31,8 @@ module SolidusSubscriptions end initializer 'solidus_subscriptions.register_promotion_rules', after: 'spree.promo.register.promotion.rules' do |app| - app.config.spree.promotions.rules << 'SolidusSubscriptions::SubscriptionPromotionRule' - app.config.spree.promotions.rules << 'SolidusSubscriptions::SubscriptionOrderPromotionRule' + app.config.spree.promotions.rules << 'SolidusSubscriptions::Promotion::Rules::SubscriptionCreationOrder' + app.config.spree.promotions.rules << 'SolidusSubscriptions::Promotion::Rules::SubscriptionInstallmentOrder' end initializer 'solidus_subscriptions.configure_backend' do diff --git a/spec/controllers/spree/admin/subscriptions_controller_spec.rb b/spec/controllers/spree/admin/subscriptions_controller_spec.rb index d64d756..6b2b3eb 100644 --- a/spec/controllers/spree/admin/subscriptions_controller_spec.rb +++ b/spec/controllers/spree/admin/subscriptions_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe Spree::Admin::SubscriptionsController, type: :request do @@ -111,75 +113,75 @@ RSpec.describe Spree::Admin::SubscriptionsController, type: :request do end describe 'POST cancel' do - subject { delete spree.cancel_admin_subscription_path(subscription) } + subject(:delete_subscription) { delete spree.cancel_admin_subscription_path(subscription) } - context 'the subscription can be canceled' do + context 'when the subscription can be canceled' do let(:subscription) { create :subscription, :actionable } it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + delete_subscription expect(flash[:notice]).to be_present end it 'cancels the subscription' do - expect { subject }.to change { subscription.reload.state }.from('active').to('canceled') + expect { delete_subscription }.to change { subscription.reload.state }.from('active').to('canceled') end end - context 'the subscription cannot be canceled' do + context 'when the subscription cannot be canceled' do let(:subscription) { create :subscription, :canceled } it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + delete_subscription expect(flash[:notice]).to be_present end it 'cancels the subscription' do - expect { subject }.not_to change { subscription.reload.state } + expect { delete_subscription }.not_to(change { subscription.reload.state }) end end end describe 'POST activate' do - subject { post spree.activate_admin_subscription_path(subscription) } + subject(:activate) { post spree.activate_admin_subscription_path(subscription) } - context 'the subscription can be activated' do + context 'when the subscription can be activated' do let(:subscription) { create :subscription, :canceled, :with_line_item } it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + activate expect(flash[:notice]).to be_present end it 'cancels the subscription' do - expect { subject }.to change { subscription.reload.state }.from('canceled').to('active') + expect { activate }.to change { subscription.reload.state }.from('canceled').to('active') end end - context 'the subscription cannot be activated' do + context 'when the subscription cannot be activated' do let(:subscription) { create :subscription, :actionable, :with_line_item } it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + activate expect(flash[:notice]).to be_present end it 'cancels the subscription' do - expect { subject }.not_to change { subscription.reload.state } + expect { activate }.not_to(change{ subscription.reload.state }) end end end describe 'POST skip' do - subject { post spree.skip_admin_subscription_path(subscription) } + subject(:skip) { post spree.skip_admin_subscription_path(subscription) } let(:subscription) { create :subscription, :actionable, :with_line_item } let!(:expected_date) { subscription.next_actionable_date } @@ -187,12 +189,12 @@ RSpec.describe Spree::Admin::SubscriptionsController, type: :request do it { is_expected.to redirect_to spree.admin_subscriptions_path } it 'has a message' do - subject + skip expect(flash[:notice]).to be_present end - it 'advances the actioanble_date' do - expect { subject }. + it 'advances the actionable_date' do + expect { skip }. to change { subscription.reload.actionable_date }. from(subscription.actionable_date).to(expected_date) end diff --git a/spec/controllers/spree/api/line_items_controller_spec.rb b/spec/controllers/spree/api/line_items_controller_spec.rb index 4571d89..8dc6390 100644 --- a/spec/controllers/spree/api/line_items_controller_spec.rb +++ b/spec/controllers/spree/api/line_items_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'spree/api/testing_support/helpers' @@ -6,7 +8,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do routes { Spree::Core::Engine.routes } describe 'POST :create' do - subject { post :create, params: params } + subject(:post_create) { post :create, params: params } let(:params) { line_item_params } let!(:variant) { create :variant } @@ -28,7 +30,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do it { is_expected.to be_created } it 'creates a line item' do - expect { subject }. + expect { post_create }. to change { Spree::LineItem.count }. from(0).to(1) end @@ -51,7 +53,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do it_behaves_like 'a new line item' it 'creates a new subscription line item' do - expect { subject }. + expect { post_create }. to change { SolidusSubscriptions::LineItem.count }. from(0).to(1) end @@ -63,7 +65,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do end describe 'patch :update' do - subject { patch :create, params: params } + subject(:patch_create) { patch :create, params: params } let(:params) { line_item_params } let!(:variant) { create :variant } @@ -93,7 +95,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do it { is_expected.to be_successful } it 'creates a new subscription line item' do - expect { subject }. + expect { patch_create }. to change { SolidusSubscriptions::LineItem.count }. from(0).to(1) end diff --git a/spec/controllers/spree/api/orders_controller_spec.rb b/spec/controllers/spree/api/orders_controller_spec.rb index 1693b5d..5f32a56 100644 --- a/spec/controllers/spree/api/orders_controller_spec.rb +++ b/spec/controllers/spree/api/orders_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'spree/api/testing_support/helpers' @@ -43,7 +45,7 @@ RSpec.describe Spree::Api::OrdersController, type: :controller do end it 'is a successful response' do - subject + subscription_line_items expect(response).to be_successful end diff --git a/spec/controllers/spree/api/users_controller_spec.rb b/spec/controllers/spree/api/users_controller_spec.rb index 0155498..5b1bb42 100644 --- a/spec/controllers/spree/api/users_controller_spec.rb +++ b/spec/controllers/spree/api/users_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'spree/api/testing_support/helpers' @@ -11,7 +13,7 @@ RSpec.describe Spree::Api::UsersController, type: :controller do let!(:subscription) { create :subscription, :with_line_item, user: user } describe 'patch /update' do - subject { patch :update, params: params } + subject(:update_user) { patch :update, params: params } let(:params) do { @@ -37,7 +39,7 @@ RSpec.describe Spree::Api::UsersController, type: :controller do end it 'updates the subscription line items' do - subject + update_user line_item = subscription.line_items.reload.first expect(line_item).to have_attributes(line_item_attributes) diff --git a/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb b/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb index 3018c0e..d3c3ce9 100644 --- a/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb +++ b/spec/decorators/controllers/solidus_subscriptions/spree/orders_controller/create_subscription_line_items_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::OrdersController::CreateSubscriptionLineItems, type: :controller do @@ -5,14 +7,14 @@ RSpec.describe SolidusSubscriptions::Spree::OrdersController::CreateSubscription routes { Spree::Core::Engine.routes } let!(:user) { create :user } - let!(:store) { create :store } before do allow(controller).to receive_messages(try_spree_current_user: user) + create :store end describe 'POST /orders/populate' do - subject { post :populate, params: params } + subject(:populate) { post :populate, params: params } let!(:variant) { create :variant } let(:params) { line_item_params } @@ -27,13 +29,13 @@ RSpec.describe SolidusSubscriptions::Spree::OrdersController::CreateSubscription it { is_expected.to redirect_to cart_path } it 'creates an order' do - expect { subject }. + expect { populate }. to change { Spree::Order.count }. from(0).to(1) end it 'creates a line item' do - expect { subject }. + expect { populate }. to change { Spree::LineItem.count }. from(0).to(1) end @@ -56,13 +58,13 @@ RSpec.describe SolidusSubscriptions::Spree::OrdersController::CreateSubscription it_behaves_like 'a new order line item' it 'creates a new subscription line item' do - expect { subject }. + expect { populate }. to change { SolidusSubscriptions::LineItem.count }. from(0).to(1) end it 'creates a subscription line item with the correct values' do - subject + populate subscription_line_item = SolidusSubscriptions::LineItem.last expect(subscription_line_item).to have_attributes( diff --git a/spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb index a0d58d5..0b43ad8 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/line_item/subscription_line_items_association_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::LineItem::SubscriptionLineItemsAssociation, type: :model do diff --git a/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscrptions_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb index fc3b74e..121afbf 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscrptions_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb @@ -1,8 +1,10 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions do describe '#finalize!' do - subject { order.finalize! } + subject(:finalize) { order.finalize! } let(:order) { create :order, :with_subscription_line_items } let(:subscription_line_item) { order.subscription_line_items.last } @@ -11,13 +13,13 @@ RSpec.describe SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions around { |e| Timecop.freeze { e.run } } it 'creates new subscriptions' do - expect { subject }. + expect { finalize }. to change { SolidusSubscriptions::Subscription.count }. by(order.subscription_line_items.count) end it 'creates a subscription with the correct values' do - subject + finalize subscription = SolidusSubscriptions::Subscription.last expect(subscription).to have_attributes( diff --git a/spec/decorators/models/solidus_subscriptions/spree/order/installment_details_association_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/order/installment_details_association_spec.rb index b87d608..98597a0 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/order/installment_details_association_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/order/installment_details_association_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::Order::InstallmentDetailsAssociation, type: :model do diff --git a/spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb index 622e14c..21e74c5 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/order/subscription_line_items_association_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::Order::SubscriptionLineItemsAssociation, type: :model do diff --git a/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb index a76f130..4047b01 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb @@ -1,7 +1,9 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::User::HaveManySubscriptions, type: :model do - subject { Spree::User.new } + subject(:user) { Spree::User.new } it { is_expected.to have_many :subscriptions } it { is_expected.to accept_nested_attributes_for :subscriptions } @@ -10,7 +12,7 @@ RSpec.describe SolidusSubscriptions::Spree::User::HaveManySubscriptions, type: : it 'throws a deprecation warning' do allow(::Spree::Deprecation).to receive(:warn) - subject.subscriptions_attributes = [{ interval_length: 2 }] + user.subscriptions_attributes = [{ interval_length: 2 }] expect(::Spree::Deprecation) .to have_received(:warn) diff --git a/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb index 422e992..56ca0cf 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/variant/auto_delete_from_subscriptions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::Spree::Variant::AutoDeleteFromSubscriptions, type: :model do diff --git a/spec/features/admin/subscriptions_spec.rb b/spec/features/admin/subscriptions_spec.rb index 1d9f698..92e1df9 100644 --- a/spec/features/admin/subscriptions_spec.rb +++ b/spec/features/admin/subscriptions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe 'Subscriptions admin' do stub_authorization! diff --git a/spec/features/admin_users_subscription_tabs_spec.rb b/spec/features/admin_users_subscription_tabs_spec.rb index f42123f..50bd93f 100644 --- a/spec/features/admin_users_subscription_tabs_spec.rb +++ b/spec/features/admin_users_subscription_tabs_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe 'User subscriptions tab', type: :feature do @@ -27,10 +29,15 @@ RSpec.describe 'User subscriptions tab', type: :feature do within('.tabs') { click_link 'Subscriptions' } end - it 'lists user subscriptions' do + it 'lists user subscriptions date' do subscriptions_table = page.find('#subscriptions-table') expect(subscriptions_table).to have_content('2020-10-21') + end + + it 'lists user subscriptions days' do + subscriptions_table = page.find('#subscriptions-table') + expect(subscriptions_table).to have_content('10 days') end diff --git a/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb b/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb index 4a33819..658e252 100644 --- a/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb +++ b/spec/jobs/solidus_subscriptions/process_installment_job_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions::ProcessInstallmentJob do it 'processes checkout for the installment' do installment = build_stubbed(:installment) @@ -8,4 +10,16 @@ RSpec.describe SolidusSubscriptions::ProcessInstallmentJob do expect(checkout).to have_received(:process) end + + context 'when handling #perform errors' do + it 'swallows error when a proc is not configured' do + expect { described_class.perform_now(nil) }.not_to raise_error(StandardError) + end + + it 'runs proc when a proc is configured' do + stub_config(processing_error_handler: proc { |e| raise e } ) + + expect { described_class.perform_now(nil) }.to raise_error(StandardError) + end + end end diff --git a/spec/lib/solidus_subscriptions/checkout_spec.rb b/spec/lib/solidus_subscriptions/checkout_spec.rb index e6c1d51..e7c18fa 100644 --- a/spec/lib/solidus_subscriptions/checkout_spec.rb +++ b/spec/lib/solidus_subscriptions/checkout_spec.rb @@ -1,5 +1,8 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions::Checkout, :checkout do context 'when the order can be created and paid' do + # rubocop:disable RSpec/MultipleExpectations it 'creates and finalizes a new order for the installment' do stub_spree_preferences(auto_capture: true) installment = create(:installment, :actionable) @@ -10,7 +13,6 @@ RSpec.describe SolidusSubscriptions::Checkout, :checkout do expect(order).to be_paid end - # rubocop:disable RSpec/MultipleExpectations it 'copies basic information from the subscription' do stub_spree_preferences(auto_capture: true) installment = create(:installment, :actionable) @@ -26,7 +28,6 @@ RSpec.describe SolidusSubscriptions::Checkout, :checkout do expect(order.user).to eq(subscription.user) expect(order.email).to eq(subscription.user.email) end - # rubocop:enable RSpec/MultipleExpectations it 'marks the order as a subscription order' do stub_spree_preferences(auto_capture: true) @@ -38,6 +39,7 @@ RSpec.describe SolidusSubscriptions::Checkout, :checkout do expect(order.subscription).to eq(subscription) expect(order.subscription_order).to eq(true) end + # rubocop:enable RSpec/MultipleExpectations it 'matches the total on the subscription' do stub_spree_preferences(auto_capture: true) diff --git a/spec/lib/solidus_subscriptions/churn_buster/client_spec.rb b/spec/lib/solidus_subscriptions/churn_buster/client_spec.rb index abb2b95..9efb2e6 100644 --- a/spec/lib/solidus_subscriptions/churn_buster/client_spec.rb +++ b/spec/lib/solidus_subscriptions/churn_buster/client_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions::ChurnBuster::Client, vcr: { cassette_name: 'churn_buster', record: :new_episodes } do describe '#report_failed_payment' do it 'reports the failed payment to Churn Buster' do diff --git a/spec/lib/solidus_subscriptions/dispatcher/failure_dispatcher_spec.rb b/spec/lib/solidus_subscriptions/dispatcher/failure_dispatcher_spec.rb index f247237..0d7db95 100644 --- a/spec/lib/solidus_subscriptions/dispatcher/failure_dispatcher_spec.rb +++ b/spec/lib/solidus_subscriptions/dispatcher/failure_dispatcher_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions::Dispatcher::FailureDispatcher do describe '#dispatch' do it 'marks the installment as failed' do diff --git a/spec/lib/solidus_subscriptions/dispatcher/out_of_stock_dispatcher_spec.rb b/spec/lib/solidus_subscriptions/dispatcher/out_of_stock_dispatcher_spec.rb index abb8343..4ad110f 100644 --- a/spec/lib/solidus_subscriptions/dispatcher/out_of_stock_dispatcher_spec.rb +++ b/spec/lib/solidus_subscriptions/dispatcher/out_of_stock_dispatcher_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions::Dispatcher::OutOfStockDispatcher do describe '#dispatch' do it 'marks the installment as out of stock' do diff --git a/spec/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher_spec.rb b/spec/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher_spec.rb index 0a222d4..103f176 100644 --- a/spec/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher_spec.rb +++ b/spec/lib/solidus_subscriptions/dispatcher/payment_failed_dispatcher_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions::Dispatcher::PaymentFailedDispatcher do describe '#dispatch' do it 'marks the installment as payment_failed' do diff --git a/spec/lib/solidus_subscriptions/dispatcher/success_dispatcher_spec.rb b/spec/lib/solidus_subscriptions/dispatcher/success_dispatcher_spec.rb index 6a71800..366e1f7 100644 --- a/spec/lib/solidus_subscriptions/dispatcher/success_dispatcher_spec.rb +++ b/spec/lib/solidus_subscriptions/dispatcher/success_dispatcher_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions::Dispatcher::SuccessDispatcher do describe '#dispatch' do it 'marks the installment as success' do diff --git a/spec/lib/solidus_subscriptions/processor_spec.rb b/spec/lib/solidus_subscriptions/processor_spec.rb index 5deaba4..18811a7 100644 --- a/spec/lib/solidus_subscriptions/processor_spec.rb +++ b/spec/lib/solidus_subscriptions/processor_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions::Processor do it 'schedules the processing of actionable subscriptions' do actionable_subscription = create(:subscription, :actionable) diff --git a/spec/lib/solidus_subscriptions/subscription_promotion_rule_spec.rb b/spec/lib/solidus_subscriptions/promotion/rules/subscription_creation_order_spec.rb index f4c65cc..e39e5b5 100644 --- a/spec/lib/solidus_subscriptions/subscription_promotion_rule_spec.rb +++ b/spec/lib/solidus_subscriptions/promotion/rules/subscription_creation_order_spec.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' -RSpec.describe SolidusSubscriptions::SubscriptionPromotionRule do +RSpec.describe SolidusSubscriptions::Promotion::Rules::SubscriptionCreationOrder do let(:rule) { described_class.new } describe '#applicable' do diff --git a/spec/lib/solidus_subscriptions/subscription_order_promotion_rule_spec.rb b/spec/lib/solidus_subscriptions/promotion/rules/subscription_installment_order_spec.rb index bacbef2..81e133d 100644 --- a/spec/lib/solidus_subscriptions/subscription_order_promotion_rule_spec.rb +++ b/spec/lib/solidus_subscriptions/promotion/rules/subscription_installment_order_spec.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + require 'spec_helper' -RSpec.describe SolidusSubscriptions::SubscriptionOrderPromotionRule do +RSpec.describe SolidusSubscriptions::Promotion::Rules::SubscriptionInstallmentOrder do let(:rule) { described_class.new } describe '#applicable' do diff --git a/spec/lib/solidus_subscriptions/subscription_generator_spec.rb b/spec/lib/solidus_subscriptions/subscription_generator_spec.rb index 02082e3..1369988 100644 --- a/spec/lib/solidus_subscriptions/subscription_generator_spec.rb +++ b/spec/lib/solidus_subscriptions/subscription_generator_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::SubscriptionGenerator do diff --git a/spec/lib/solidus_subscriptions_spec.rb b/spec/lib/solidus_subscriptions_spec.rb index 201c576..f99119f 100644 --- a/spec/lib/solidus_subscriptions_spec.rb +++ b/spec/lib/solidus_subscriptions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions do describe '.churn_buster' do context 'when Churn Buster was configured' do diff --git a/spec/models/solidus_subscriptions/installment_detail_spec.rb b/spec/models/solidus_subscriptions/installment_detail_spec.rb index 53f0b53..8c03f4d 100644 --- a/spec/models/solidus_subscriptions/installment_detail_spec.rb +++ b/spec/models/solidus_subscriptions/installment_detail_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::InstallmentDetail, type: :model do @@ -6,13 +8,13 @@ RSpec.describe SolidusSubscriptions::InstallmentDetail, type: :model do describe '#failed?' do subject { build(:installment_detail, success: success).failed? } - context 'the detail was successful' do + context 'when the detail was successful' do let(:success) { true } it { is_expected.to be_falsy } end - context 'the detail was not successfuly' do + context 'when the detail was not successfuly' do let(:success) { false } it { is_expected.to be_truthy } diff --git a/spec/models/solidus_subscriptions/installment_spec.rb b/spec/models/solidus_subscriptions/installment_spec.rb index 399a7e6..289bf8a 100644 --- a/spec/models/solidus_subscriptions/installment_spec.rb +++ b/spec/models/solidus_subscriptions/installment_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::Installment, type: :model do @@ -6,7 +8,7 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do it { is_expected.to validate_presence_of :subscription } describe '#out_of_stock' do - subject { installment.out_of_stock } + subject(:out_of_stock) { installment.out_of_stock } let(:expected_date) do Time.zone.today + SolidusSubscriptions.configuration.reprocessing_interval @@ -16,20 +18,20 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do it { is_expected.not_to be_successful } it 'has the correct message' do - expect(subject).to have_attributes( + expect(out_of_stock).to have_attributes( message: I18n.t('solidus_subscriptions.installment_details.out_of_stock') ) end it 'advances the installment actionable_date' do - subject + out_of_stock actionable_date = installment.reload.actionable_date expect(actionable_date).to eq expected_date end end describe '#success!' do - subject { installment.success!(order) } + subject(:success) { installment.success!(order) } let(:order) { create :order } @@ -37,19 +39,19 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do let(:actionable_date) { 1.month.from_now.to_date } it 'removes any actionable date if any' do - expect { subject }. + expect { success }. to change(installment, :actionable_date). from(actionable_date).to(nil) end it 'creates a new installment detail' do - expect { subject }. + expect { success }. to change { SolidusSubscriptions::InstallmentDetail.count }. by(1) end it 'creates a successful installment detail' do - subject + success expect(installment.details.last).to be_successful && have_attributes( order: order, message: I18n.t('solidus_subscriptions.installment_details.success') @@ -58,7 +60,7 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do end describe '#failed!' do - subject { installment.failed!(order) } + subject(:failed) { installment.failed!(order) } let(:order) { create :order } @@ -70,23 +72,23 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do it { is_expected.not_to be_successful } it 'has the correct message' do - expect(subject).to have_attributes( + expect(failed).to have_attributes( message: I18n.t('solidus_subscriptions.installment_details.failed'), order: order ) end it 'advances the installment actionable_date' do - subject + failed actionable_date = installment.reload.actionable_date expect(actionable_date).to eq expected_date end - context 'the reprocessing interval is set to nil' do + context 'when the reprocessing interval is set to nil' do before { stub_config(reprocessing_interval: nil) } it 'does not advance the installment actionable_date' do - subject + failed actionable_date = installment.reload.actionable_date expect(actionable_date).to be_nil end @@ -98,13 +100,13 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do let(:installment) { create(:installment, details: details) } - context 'the installment has an associated successful detail' do + context 'when the installment has an associated successful detail' do let(:details) { create_list :installment_detail, 1, success: true } it { is_expected.to be_falsy } end - context 'the installment has no associated successful detail' do + context 'when the installment has no associated successful detail' do let(:details) { create_list :installment_detail, 1 } it { is_expected.to be_truthy } @@ -116,13 +118,13 @@ RSpec.describe SolidusSubscriptions::Installment, type: :model do let(:installment) { create(:installment, details: details) } - context 'the installment has an associated completed order' do + context 'when the installment has an associated completed order' do let(:details) { create_list :installment_detail, 1, success: true } it { is_expected.to be_truthy } end - context 'the installment has no associated completed order' do + context 'when the installment has no associated completed order' do let(:details) { create_list :installment_detail, 1 } it { is_expected.to be_falsy } diff --git a/spec/models/solidus_subscriptions/line_item_spec.rb b/spec/models/solidus_subscriptions/line_item_spec.rb index aaa24a5..d7c1bdb 100644 --- a/spec/models/solidus_subscriptions/line_item_spec.rb +++ b/spec/models/solidus_subscriptions/line_item_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::LineItem, type: :model do @@ -7,7 +9,7 @@ RSpec.describe SolidusSubscriptions::LineItem, type: :model do it { is_expected.to validate_numericality_of(:interval_length).is_greater_than(0) } describe "#interval" do - subject { line_item.interval } + subject(:interval) { line_item.interval } let(:line_item) { create :subscription_line_item, :with_subscription } @@ -21,7 +23,7 @@ RSpec.describe SolidusSubscriptions::LineItem, type: :model do it { is_expected.to be_a ActiveSupport::Duration } it "calculates the duration correctly" do - expect(subject.from_now).to eq Date.parse("2016-10-22") + expect(interval.from_now).to eq Date.parse("2016-10-22") end end end diff --git a/spec/models/solidus_subscriptions/subscription_spec.rb b/spec/models/solidus_subscriptions/subscription_spec.rb index 0d0f047..6b05cce 100644 --- a/spec/models/solidus_subscriptions/subscription_spec.rb +++ b/spec/models/solidus_subscriptions/subscription_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe SolidusSubscriptions::Subscription, type: :model do @@ -112,7 +114,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do allow(SolidusSubscriptions.configuration).to receive(:minimum_cancellation_notice) { minimum_cancellation_notice } end - context 'the subscription can be canceled' do + context 'when the subscription can be canceled' do let(:actionable_date) { 1.month.from_now } let(:minimum_cancellation_notice) { 1.day } @@ -127,7 +129,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do end end - context 'the subscription cannot be canceled' do + context 'when the subscription cannot be canceled' do let(:actionable_date) { Date.current } let(:minimum_cancellation_notice) { 1.day } @@ -221,7 +223,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do end end - context 'the subscription can be deactivated' do + context 'when the subscription can be deactivated' do let(:attributes) do { end_date: Date.current.ago(2.days) } end @@ -237,7 +239,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do end end - context 'the subscription cannot be deactivated' do + context 'when the subscription cannot be deactivated' do it { is_expected.to be_falsy } it 'does not create an event' do @@ -271,7 +273,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do end end - context 'the subscription cannot be activated' do + context 'when the subscription cannot be activated' do it 'returns false' do subscription = create(:subscription, actionable_date: Time.zone.today) @@ -410,25 +412,25 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do let!(:failed_subs) { create_list(:installment, 2, :failed).map(&:subscription) } let!(:success_subs) { create_list(:installment, 2, :success).map(&:subscription) } - context 'successfull subscriptions' do + context 'with successfull subscriptions' do let(:state) { :success } it { is_expected.to match_array success_subs } end - context 'failed subscriptions' do + context 'with failed subscriptions' do let(:state) { :failed } it { is_expected.to match_array failed_subs } end - context 'new subscriptions' do + context 'with new subscriptions' do let(:state) { :pending } it { is_expected.to match_array new_subs } end - context 'unknown state' do + context 'with unknown state' do let(:state) { :foo } it 'raises an error' do diff --git a/spec/models/spree/variant_spec.rb b/spec/models/spree/variant_spec.rb index d1aff3d..3627fc7 100644 --- a/spec/models/spree/variant_spec.rb +++ b/spec/models/spree/variant_spec.rb @@ -1,14 +1,16 @@ +# frozen_string_literal: true + require 'spec_helper' RSpec.describe Spree::Variant, type: :model do let(:variant) { build_stubbed :variant } describe "#pretty_name" do - subject { variant.pretty_name } + subject(:pretty_name) { variant.pretty_name } it 'includes the product and options', :aggregate_failures do - expect(subject).to match variant.name - expect(subject).to match variant.options_text + expect(pretty_name).to match variant.name + expect(pretty_name).to match variant.options_text end end end diff --git a/spec/models/spree/wallet_payment_source_spec.rb b/spec/models/spree/wallet_payment_source_spec.rb index 374e235..ff057f9 100644 --- a/spec/models/spree/wallet_payment_source_spec.rb +++ b/spec/models/spree/wallet_payment_source_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Spree::WalletPaymentSource do describe 'setting it as the default' do it 'reports a payment method changed event for subscriptions that use the default payment source' do diff --git a/spec/requests/api/v1/line_items_spec.rb b/spec/requests/api/v1/line_items_spec.rb index c6e34e6..d5fa6b4 100644 --- a/spec/requests/api/v1/line_items_spec.rb +++ b/spec/requests/api/v1/line_items_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe '/api/v1/line_items' do include SolidusSubscriptions::Engine.routes.url_helpers diff --git a/spec/requests/api/v1/subscriptions_spec.rb b/spec/requests/api/v1/subscriptions_spec.rb index 0406ea7..6807c67 100644 --- a/spec/requests/api/v1/subscriptions_spec.rb +++ b/spec/requests/api/v1/subscriptions_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe '/api/v1/subscriptions' do include SolidusSubscriptions::Engine.routes.url_helpers diff --git a/spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb b/spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb index 11ada2c..a3e9a23 100644 --- a/spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb +++ b/spec/subscribers/solidus_subscriptions/churn_buster_subscriber_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SolidusSubscriptions::ChurnBusterSubscriber do describe '#report_subscription_cancellation' do it 'reports the cancellation to Churn Buster' do |