Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subs track their own interval now #21

Merged
merged 1 commit into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/models/solidus_subscriptions/line_item.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# The LineItem class is responsible for associating Line items to subscriptions.
# It tracks the following values:
# The LineItem class is responsible for associating Line items to subscriptions. # It tracks the following values:
#
# [Spree::LineItem] :spree_line_item The spree object which created this instance
#
Expand Down Expand Up @@ -53,6 +52,10 @@ def dummy_line_item
li.freeze
end

def interval
subscription.try!(:interval) || super
end

private

# Get a placeholder order for calculating the values of future
Expand All @@ -68,7 +71,7 @@ def dummy_order
# A place holder for calculating dynamic values needed to display in the cart
# it is frozen and cannot be saved
def dummy_subscription
Subscription.new(line_items: [dup]).freeze
Subscription.new(line_items: [dup], interval_length: interval_length, interval_units: interval_units).freeze
end

def update_actionable_date_if_interval_changed
Expand Down
4 changes: 2 additions & 2 deletions app/models/solidus_subscriptions/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class Subscription < ActiveRecord::Base
# The following methods are delegated to the associated
# SolidusSubscriptions::LineItem
#
# :interval, :quantity, :subscribable_id, :end_date
delegate :interval, :quantity, :subscribable_id, :end_date, to: :line_item
# :quantity, :subscribable_id
delegate :quantity, :subscribable_id, to: :line_item

# Find all subscriptions that are "actionable"; that is, ones that have an
# actionable_date in the past and are not invalid or canceled.
Expand Down