summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan Deere <brendan@stembolt.com>2017-01-13 11:56:13 -0800
committerBrendan <brendan@stembolt.com>2017-02-03 10:08:09 -0800
commitb01c9d05dcb4e4e5d82577e3b055486020ce4d33 (patch)
treeba23a4b492cc338335f98f37fc51c290fb0176a6
parent9f3a33f2bc7bf76801fb3e2db68e4b3906647b9c (diff)
Add Subscription configuration values
:end_date, :interval_length and :interval_units are stored on the subscription line items before the order is completed. Once the order is completed we want a canonical source for these values. These values will now be stored on the subscription itself, once it is created
-rw-r--r--db/migrate/20170112012407_add_config_options_to_subscriptions.rb7
-rw-r--r--lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb2
-rw-r--r--spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb4
3 files changed, 11 insertions, 2 deletions
diff --git a/db/migrate/20170112012407_add_config_options_to_subscriptions.rb b/db/migrate/20170112012407_add_config_options_to_subscriptions.rb
new file mode 100644
index 0000000..6020179
--- /dev/null
+++ b/db/migrate/20170112012407_add_config_options_to_subscriptions.rb
@@ -0,0 +1,7 @@
+class AddConfigOptionsToSubscriptions < ActiveRecord::Migration
+ def change
+ add_column :solidus_subscriptions_subscriptions, :interval_length, :integer
+ add_column :solidus_subscriptions_subscriptions, :interval_units, :integer
+ add_column :solidus_subscriptions_subscriptions, :end_date, :datetime
+ end
+end
diff --git a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
index 61baa33..222f9ef 100644
--- a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
+++ b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
@@ -1,6 +1,8 @@
FactoryGirl.define do
factory :subscription, class: 'SolidusSubscriptions::Subscription' do
store
+ interval_length 1
+ interval_units :month
user do
ccs = build_list(:credit_card, 1, gateway_customer_profile_id: 'BGS-123', default: true)
diff --git a/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb b/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb
index 3950684..62723a8 100644
--- a/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb
+++ b/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe "Subscription endpoints", type: :request do
describe "#cancel" do
let(:subscription) do
- create :subscription, actionable_date: (Date.current + 1.month), user: user
+ create :subscription, :with_line_item, actionable_date: (Date.current + 1.month), user: user
end
it "returns the canceled record", :aggregate_failures do
@@ -18,7 +18,7 @@ RSpec.describe "Subscription endpoints", type: :request do
context 'when the miniumum notice has been past' do
let(:subscription) do
- create :subscription, actionable_date: Date.current, user: user
+ create :subscription, :with_line_item, actionable_date: Date.current, user: user
end
it "returns the record pending cancellation", :aggregate_failures do