From 5b01d2a962f7bda1a33c3d88c2db36af6d1de072 Mon Sep 17 00:00:00 2001 From: Alessandro Desantis Date: Mon, 27 Jul 2020 14:37:32 +0200 Subject: Update default permitted attributes The billing address as well as the interval and end date can now be set directly on the subscription, so we need to permit those attributes by default. --- lib/solidus_subscriptions/engine.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib/solidus_subscriptions/engine.rb') diff --git a/lib/solidus_subscriptions/engine.rb b/lib/solidus_subscriptions/engine.rb index 39cb754..8b5b083 100644 --- a/lib/solidus_subscriptions/engine.rb +++ b/lib/solidus_subscriptions/engine.rb @@ -20,19 +20,22 @@ module SolidusSubscriptions g.test_framework :rspec end - initializer 'configure spree subcription permitted attributes', after: 'require subscription lib helpers' do - PermittedAttributes.update_spree_permiteed_attributes + initializer 'solidus_subscriptions.update_permitted_attributes' do + ::Spree::PermittedAttributes.line_item_attributes << { + subscription_line_items_attributes: PermittedAttributes.subscription_line_item_attributes | [:id], + } + + ::Spree::PermittedAttributes.user_attributes << { + subscriptions_attributes: PermittedAttributes.subscription_attributes | [:id], + } end - initializer 'solidus_subscriptions.configs', before: "require subscription lib helpers" do - end - - initializer 'register_subscription_promotion_rule', after: 'spree.promo.register.promotion.rules' do |app| + 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' end - initializer 'subscriptions_backend' do + 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( -- cgit v1.2.3