summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/solidus_subscriptions/subscription.rb3
-rw-r--r--db/migrate/20170111224458_change_subscription_actionable_date_to_datetime.rb5
-rw-r--r--lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb4
-rw-r--r--spec/models/solidus_subscriptions/subscription_spec.rb2
-rw-r--r--spec/overrides/spree/orders/finalize_creates_subscrptions_spec.rb2
-rw-r--r--spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb2
6 files changed, 12 insertions, 6 deletions
diff --git a/app/models/solidus_subscriptions/subscription.rb b/app/models/solidus_subscriptions/subscription.rb
index 8d8dbf4..e9e2438 100644
--- a/app/models/solidus_subscriptions/subscription.rb
+++ b/app/models/solidus_subscriptions/subscription.rb
@@ -154,7 +154,8 @@ module SolidusSubscriptions
# eligible to be processed.
def next_actionable_date
return nil unless active?
- (actionable_date || Time.zone.now) + interval
+ new_date = (actionable_date || Time.zone.now)
+ (new_date + interval).beginning_of_minute
end
# Advance the actionable date to the next_actionable_date value. Will modify
diff --git a/db/migrate/20170111224458_change_subscription_actionable_date_to_datetime.rb b/db/migrate/20170111224458_change_subscription_actionable_date_to_datetime.rb
new file mode 100644
index 0000000..25792f2
--- /dev/null
+++ b/db/migrate/20170111224458_change_subscription_actionable_date_to_datetime.rb
@@ -0,0 +1,5 @@
+class ChangeSubscriptionActionableDateToDatetime < ActiveRecord::Migration
+ def change
+ change_column :solidus_subscriptions_subscriptions, :actionable_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 d434d2a..0528c14 100644
--- a/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
+++ b/lib/solidus_subscriptions/testing_support/factories/subscription_factory.rb
@@ -17,12 +17,12 @@ FactoryGirl.define do
trait :actionable do
with_line_item
- actionable_date { Time.zone.now.yesterday }
+ actionable_date { Time.zone.now.yesterday.beginning_of_minute }
end
trait :not_actionable do
with_line_item
- actionable_date { Time.zone.now.tomorrow }
+ actionable_date { Time.zone.now.tomorrow.beginning_of_minute }
end
trait(:pending_cancellation) do
diff --git a/spec/models/solidus_subscriptions/subscription_spec.rb b/spec/models/solidus_subscriptions/subscription_spec.rb
index 3309f0e..65c99af 100644
--- a/spec/models/solidus_subscriptions/subscription_spec.rb
+++ b/spec/models/solidus_subscriptions/subscription_spec.rb
@@ -47,7 +47,7 @@ RSpec.describe SolidusSubscriptions::Subscription, type: :model do
let(:total_skips) { 0 }
let(:successive_skips) { 0 }
- let(:expected_date) { 1.month.from_now.to_date }
+ let(:expected_date) { 1.month.from_now.beginning_of_minute }
let(:subscription) do
create(
diff --git a/spec/overrides/spree/orders/finalize_creates_subscrptions_spec.rb b/spec/overrides/spree/orders/finalize_creates_subscrptions_spec.rb
index cdb3bf8..999c5f4 100644
--- a/spec/overrides/spree/orders/finalize_creates_subscrptions_spec.rb
+++ b/spec/overrides/spree/orders/finalize_creates_subscrptions_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe Spree::Orders::FinalizeCreatesSubscriptions do
let(:order) { create :order, :with_subscription_line_items }
let(:subscription_line_item) { order.subscription_line_items.last }
- let(:expected_actionable_date) { (Date.current + subscription_line_item.interval).to_date }
+ let(:expected_actionable_date) { (DateTime.current + subscription_line_item.interval).beginning_of_minute }
around { |e| Timecop.freeze { e.run } }
diff --git a/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb b/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb
index 06105c6..3950684 100644
--- a/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb
+++ b/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb
@@ -33,7 +33,7 @@ RSpec.describe "Subscription endpoints", type: :request do
before { Timecop.freeze(Date.parse("2016-09-26")) }
after { Timecop.return }
- let(:expected_date) { "2016-10-27" }
+ let(:expected_date) { "2016-10-27T00:00:00.000Z" }
it "returns the updated record", :aggregate_failures do
post solidus_subscriptions.skip_api_v1_subscription_path(subscription), token: user.spree_api_key