diff options
-rw-r--r-- | .travis.yml | 6 | ||||
-rw-r--r-- | Gemfile | 3 | ||||
-rw-r--r-- | lib/solidus_subscriptions/config.rb | 94 | ||||
-rw-r--r-- | solidus_subscriptions.gemspec | 2 | ||||
-rw-r--r-- | spec/controllers/spree/admin/subscriptions_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/solidus_subscriptions/processor_spec.rb | 3 |
6 files changed, 59 insertions, 51 deletions
diff --git a/.travis.yml b/.travis.yml index 4335ae0..1722ee5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,17 @@ env: - SOLIDUS_BRANCH=v1.2 DB=postgres - SOLIDUS_BRANCH=v1.3 DB=postgres - SOLIDUS_BRANCH=v1.4 DB=postgres + - SOLIDUS_BRANCH=v2.0 DB=postgres + - SOLIDUS_BRANCH=v2.1 DB=postgres + - SOLIDUS_BRANCH=master DB=postgres - SOLIDUS_BRANCH=v1.0 DB=mysql - SOLIDUS_BRANCH=v1.1 DB=mysql - SOLIDUS_BRANCH=v1.2 DB=mysql - SOLIDUS_BRANCH=v1.3 DB=mysql - SOLIDUS_BRANCH=v1.4 DB=mysql + - SOLIDUS_BRANCH=v2.0 DB=mysql + - SOLIDUS_BRANCH=v2.1 DB=mysql + - SOLIDUS_BRANCH=master DB=mysql before_script: - bundle exec rake test_app @@ -1,11 +1,12 @@ source 'https://rubygems.org' -branch = ENV.fetch('SOLIDUS_BRANCH', 'v1.4') +branch = ENV.fetch('SOLIDUS_BRANCH', 'master') gem 'solidus', github: 'solidusio/solidus', branch: branch # Provides basic authentication functionality for testing parts of your engine gem 'solidus_auth_devise', '~> 1.0' gem 'pg' gem 'mysql2' +gem 'listen' gemspec diff --git a/lib/solidus_subscriptions/config.rb b/lib/solidus_subscriptions/config.rb index 18ba9ec..3b6f714 100644 --- a/lib/solidus_subscriptions/config.rb +++ b/lib/solidus_subscriptions/config.rb @@ -32,62 +32,62 @@ module SolidusSubscriptions @out_of_stock_dispatcher_class ||= ::SolidusSubscriptions::OutOfStockDispatcher end - # Maximum number of times a user can skip their subscription before it - # must be processed - mattr_accessor(:maximum_successive_skips) { 1 } + def default_gateway(&block) + return @gateway.call unless block_given? + @gateway = block + end + end - # Limit on the number of times a user can skip thier subscription. Once - # this limit is reached, no skips are permitted - mattr_accessor(:maximum_total_skips) { nil } + # Maximum number of times a user can skip their subscription before it + # must be processed + mattr_accessor(:maximum_successive_skips) { 1 } - # Time between an installment failing to be processed and the system - # retrying to fulfil it - mattr_accessor(:reprocessing_interval) { 1.day } + # Limit on the number of times a user can skip thier subscription. Once + # this limit is reached, no skips are permitted + mattr_accessor(:maximum_total_skips) { nil } - mattr_accessor(:minimum_cancellation_notice) { 1.day } + # Time between an installment failing to be processed and the system + # retrying to fulfil it + mattr_accessor(:reprocessing_interval) { 1.day } - # Which queue is responsible for processing subscriptions - mattr_accessor(:processing_queue) { :default } + mattr_accessor(:minimum_cancellation_notice) { 1.day } - # SolidusSubscriptions::LineItem attributes which are allowed to - # be updated from user data - # - # This is useful in the case where certain fields should not be allowed to - # be modified by the user. This locks these attributes from being passed - # in to the orders controller (or the api controller). + # Which queue is responsible for processing subscriptions + mattr_accessor(:processing_queue) { :default } - # Ie. if a store does not want to allow users to configure the number of - # installments they will receive. Add this to an initializer: + # SolidusSubscriptions::LineItem attributes which are allowed to + # be updated from user data + # + # This is useful in the case where certain fields should not be allowed to + # be modified by the user. This locks these attributes from being passed + # in to the orders controller (or the api controller). - # ``` - # SolidusSubscriptions::Config.subscription_line_item_attributes = [ - # :quantity, - # :interval_length, - # :interval_units, - # :subscribable_id - # ] - # ``` + # Ie. if a store does not want to allow users to configure the number of + # installments they will receive. Add this to an initializer: - # This configuration also easily allows the gem to be customized to track - # more information on the subcriptions line items. - mattr_accessor(:subscription_line_item_attributes) do - [ - :quantity, - :subscribable_id, - :interval_length, - :interval_units, - :max_installments - ] - end + # ``` + # SolidusSubscriptions::Config.subscription_line_item_attributes = [ + # :quantity, + # :interval_length, + # :interval_units, + # :subscribable_id + # ] + # ``` - # SolidusSubscriptions::Subscription attributes which are allowed to - # be updated from user data - mattr_accessor(:subscription_attributes) { [:actionable_date] } - - def default_gateway(&block) - return @gateway.call unless block_given? - @gateway = block - end + # This configuration also easily allows the gem to be customized to track + # more information on the subcriptions line items. + mattr_accessor(:subscription_line_item_attributes) do + [ + :quantity, + :subscribable_id, + :interval_length, + :interval_units, + :max_installments + ] end + + # SolidusSubscriptions::Subscription attributes which are allowed to + # be updated from user data + mattr_accessor(:subscription_attributes) { [:actionable_date] } end end diff --git a/solidus_subscriptions.gemspec b/solidus_subscriptions.gemspec index cfa5779..ee51079 100644 --- a/solidus_subscriptions.gemspec +++ b/solidus_subscriptions.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*", 'LICENSE', 'Rakefile', 'README.md'] s.test_files = Dir['test/**/*'] - s.add_dependency 'solidus', '< 2.0' + s.add_dependency 'solidus' s.add_dependency 'deface' s.add_dependency 'state_machines' s.add_dependency 'i18n' diff --git a/spec/controllers/spree/admin/subscriptions_controller_spec.rb b/spec/controllers/spree/admin/subscriptions_controller_spec.rb index f6637d8..a026cf5 100644 --- a/spec/controllers/spree/admin/subscriptions_controller_spec.rb +++ b/spec/controllers/spree/admin/subscriptions_controller_spec.rb @@ -8,14 +8,12 @@ RSpec.describe Spree::Admin::SubscriptionsController, type: :controller do subject { get :index } it { is_expected.to be_successful } - it { is_expected.to render_template :index } end describe 'GET :new' do subject { get :new } it { is_expected.to be_successful } - it { is_expected.to render_template :new } end describe 'POST cancel' do diff --git a/spec/lib/solidus_subscriptions/processor_spec.rb b/spec/lib/solidus_subscriptions/processor_spec.rb index f9d001e..e4b2cd8 100644 --- a/spec/lib/solidus_subscriptions/processor_spec.rb +++ b/spec/lib/solidus_subscriptions/processor_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe SolidusSubscriptions::Processor, :checkout do + include ActiveJob::TestHelper + around { |e| perform_enqueued_jobs { e.run } } + let(:user) do ccs = build_list(:credit_card, 1, gateway_customer_profile_id: 'BGS-123', default: true) build :user, credit_cards: ccs |